2017-07-19 62 views
0

假设我有一个输入字段:<input type="text" placeholder="Select Teams" />,我应该可以通过单击输入字段来选择Support如何在Vue的输入表格中使用选择

enter image description here

然后

enter image description here

我才知道,这是可能的使用selectize。我应该如何将它作为一个vue指令?

+0

您应等待组件更改。查看https://github.com/selectize/selectize.js/blob/master/docs/events.md和https://github.com/selectize/selectize.js/blob/master/docs/usage.md(特别是'onItemAdd') –

回答

2

试试这个。

Vue.directive('selectize', function(el, binding){ 
    var options = binding.value || {} 
    $(el).selectize(options) 
}) 

然后使用v-selectize指令,你想要的。

您还可以添加更多选项。例如:

<input v-selectize="{maxItems: 3}" type="text" placeholder="Select Teams" /> 
相关问题