我尝试使用显示所有国家/地区的v-select.所以我做了 :
<v-select on-change="updateCountryId" label="country_name" :options="countries" ></v-select>
Run Code Online (Sandbox Code Playgroud)
它工作得很好并显示我的国家,但函数updateCountryId似乎不起作用
methods: {
updateCountryId: function() {
alert('ok');
}
}
Run Code Online (Sandbox Code Playgroud)
但我从来没有看到好的
导入vue-select我做了:
<script src="/js/vue-select/vue-select.js"> </script>
Run Code Online (Sandbox Code Playgroud)
我在twig文件中使用它,所以在我的vue-select.js中,我重写了我在https://unpkg.com/vue-select@1.3.3上找到的内容,但用{%}>替换了{{}}
ps:我已经尝试过v-on:change,@ change和onChange
我的代码看起来像那样(我跳过我认为没用的东西)
<div id="General">
<div class="form-group">
<label>Pays :</label>
<v-select onChange="updateCountryId" label="country_name" :options="countries" ></v-select>
</div>
.
.
.
<script src="/js/vue-select/vue-select.js"> </script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/vue/1.0.13/vue.min.js"></script>
<script>
Vue.config.delimiters = ['<%', '%>'];
Vue.component('v-select', VueSelect.VueSelect);
var vm = new Vue({
el: "#General",
data: {
countries: [],
},
filters: {
},
methods: {
updateCountryId: function () {
console.log('ok');
alert('ok');
},`
Run Code Online (Sandbox Code Playgroud) vue.js ×1