简体   繁体   中英

Chrome doesn't work for vuejs v-on:click in option tag

I have something like the following code :

<select>
  <option v-for="category in step4.categoryList" v-on:click="setCategoryId(category.id)">
     @{{category.category_name }}
  </option>
</select>

It works fine in firefox but doesn't work in chrome and safari. in other words @click doesn't work in chrome when it's in an option tag.

It's obvious that I'm using vuejs.

any idea?

Click event on option tag is not supposed to fire at all. Don't rely on it. Bind onchange event on select:

<select v-on:change="setCategoryId">
  <option
    v-for="category in step4.categoryList"
    :value="category.id">
    @{{category.category_name }}
  </option>
</select>

Then in setCategoryId take event.target.value , it will be your id.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM