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

I have something like the following code :<select><option v-for="category in step4.catego

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?

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?

Share Improve this question edited Jul 4, 2018 at 20:14 Derek Pollard 7,1756 gold badges43 silver badges60 bronze badges asked Jul 4, 2018 at 19:04 blank94blank94 3945 silver badges21 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 8

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.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745132563a4613043.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信