Vuejs2 使用选择选项作为条件,Vuejs和vuetify
嘿,我想在两个不同的东西之间做一个下拉选择的改变。在此示例代码中,更改发生在两个console.log之间。当我运行这段代码时,我需要在方法进入另一个语句之前选择一个选项两次。为什么会这样?我怎样才能解决这个问题Vuejs2 使用选择选项作为条件,Vuejs和vuetify,vuejs2,vuetify.js,Vuejs2,Vuetify.js,嘿,我想在两个不同的东西之间做一个下拉选择的改变。在此示例代码中,更改发生在两个console.log之间。当我运行这段代码时,我需要在方法进入另一个语句之前选择一个选项两次。为什么会这样?我怎样才能解决这个问题 <v-select v-model="category" :items="categories" item-text="text" item-value="value"
<v-select
v-model="category"
:items="categories"
item-text="text"
item-value="value"
single-line
auto
label="Filter"
prepend-icon="search"
@change="a();"
>
</v-select>
export default {
data (){
return {
category: null,
categories: [
{
value: 1,
text: 'Arbete',
selected: true
},
{
value: 2,
text: 'Arbetare',
selected: false
}
]
}
},
methods: {
a (){
if(this.category == 1){
console.log("work " + this.category)
}else{
console.log("labour "+ this.category)
}
}
}
使用
这管用!非常感谢!我想我需要阅读更多关于nextTick函数的内容!
methods: {
a() {
this.$nextTick(() => {
if (this.category == 1) {
console.log("work " + this.category)
} else {
console.log("labour " + this.category)
}
})
},
}