Vue-multiselect: Can't set placeholder to prop

Created on 3 Jun 2016  Â·  3Comments  Â·  Source: shentao/vue-multiselect

I'm trying to do something like this:

<multiselect
    :selected.sync="selected"
    :show-labels="false"
    :options="languages"
    placeholder="languagePlaceholder"
></multiselect>

Where languagePlaceholder is a component prop. I tried placeholder="languagePlaceholder" and placeholder="{{ languagePlaceholder }}", both just output a string, not the value of the prop.

question

Most helpful comment

Hey @zachleigh! Thanks for using vue-multiselect!

This is because if you use simple placeholder="languagePlaceholder" it will pass languagePlaceholder as a string. Using {{ languagePlaceholder }} won’t help as it evaluates the expression inside the brackets before passing it down to the component.
However, if you use the dynamic prop syntax – v-bind:placeholder="languagePlaceholder" or the shorthand version of it :placeholder="languagePlaceholder" it will pass the languagePlaceholder object as props. Similar to the :options props.

So simplty add the : before the placeholder props and it should fix the problem

Read https://vuejs.org/guide/components.html#Literal-vs-Dynamic for more information!

Let me know if this helps (I hope so!) or if there are any other problems!
Cheers!

All 3 comments

Hey @zachleigh! Thanks for using vue-multiselect!

This is because if you use simple placeholder="languagePlaceholder" it will pass languagePlaceholder as a string. Using {{ languagePlaceholder }} won’t help as it evaluates the expression inside the brackets before passing it down to the component.
However, if you use the dynamic prop syntax – v-bind:placeholder="languagePlaceholder" or the shorthand version of it :placeholder="languagePlaceholder" it will pass the languagePlaceholder object as props. Similar to the :options props.

So simplty add the : before the placeholder props and it should fix the problem

Read https://vuejs.org/guide/components.html#Literal-vs-Dynamic for more information!

Let me know if this helps (I hope so!) or if there are any other problems!
Cheers!

Perfect! Thanks @shentao

No problem! Good luck with your app! If you have any other questions, problems or feature requests – let me know! 👍

Was this page helpful?
0 / 5 - 0 ratings

Related issues

wujekbogdan picture wujekbogdan  Â·  4Comments

bushcode picture bushcode  Â·  3Comments

volkanciloglu picture volkanciloglu  Â·  3Comments

alexhyriavets picture alexhyriavets  Â·  3Comments

hskrishna29 picture hskrishna29  Â·  3Comments