PeptideChain
PeptideChain

Reputation: 563

Array property in vue.js

If I define a property for a component MyComp1 like that

props: {
  display: {
    type: [Boolean, Array],
    validator: function (value) {
      return value === false && value !== true;
    },
    default: false,
  },
},

How can I use it in my component MyComp2? I tried different syntax's

<MyComp1 display=[mobile, tablet]><MyComp1>
<MyComp1 display="['mobile', 'tablet']"><MyComp1>
<MyComp1 display="mobile,tablet"><MyComp1>

but none works. Which is the right syntax?

Upvotes: 2

Views: 2019

Answers (1)

M. Gara
M. Gara

Reputation: 1078

You are missing the colon before 'display'

<MyComp1 :display="['mobile', 'tablet']"><MyComp1>

instead of

<MyComp1 display="['mobile', 'tablet']"><MyComp1>

Upvotes: 2

Related Questions