Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/elixir/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Vuejs2 使用选择选项作为条件,Vuejs和vuetify_Vuejs2_Vuetify.js - Fatal编程技术网

Vuejs2 使用选择选项作为条件,Vuejs和vuetify

Vuejs2 使用选择选项作为条件,Vuejs和vuetify,vuejs2,vuetify.js,Vuejs2,Vuetify.js,嘿,我想在两个不同的东西之间做一个下拉选择的改变。在此示例代码中,更改发生在两个console.log之间。当我运行这段代码时,我需要在方法进入另一个语句之前选择一个选项两次。为什么会这样?我怎样才能解决这个问题 <v-select v-model="category" :items="categories" item-text="text" item-value="value"

嘿,我想在两个不同的东西之间做一个下拉选择的改变。在此示例代码中,更改发生在两个console.log之间。当我运行这段代码时,我需要在方法进入另一个语句之前选择一个选项两次。为什么会这样?我怎样才能解决这个问题

        <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)
             }
         })
     },
  }