guyaloni
guyaloni

Reputation: 5922

Vue prop validation is not called

I create a component with input properties:

export default {
    data() {
       :
       :
    },     
    props: {
        rowsContent: {
            type: Object,
            default: null,
            validator: function(value) {
                console.log("In validator");
            }

        },
        rowsPerPage: {
            type: Number,
            default: 10,
        },
    }

I tried to pass different type of parameters, and got no error message.
Moreover, no "In validator" message is printed to console.

Any idea?

Upvotes: 2

Views: 1421

Answers (1)

Nafees Anwar
Nafees Anwar

Reputation: 6608

I don't know the reason, but it is working if I use component tag like <tag></tag>. If I use like <tag/>, it does not work. See example here. https://codesandbox.io/s/z6rlzl998p

EDIT: Vue does not support self-closing tags as components: https://github.com/vuejs/vue/issues/8664 (as mentioned in comment)

Upvotes: 3

Related Questions