I'm trying to fire the foo() function with the @click but as you can see, need press the radio button two times to fire the event correctly . Only catch the value the second time that you press...

我正在尝试使用@click启动foo()函数,但正如您所看到的,需要按两次单选按钮才能正确触发事件。只有第二次按下时才能抓住价值......

I want to fire the event without @click only fire the event when v-model (srStatus) changes.

我想在没有@click的情况下触发事件,只在v-model(srStatus)发生变化时触发事件。

here is my Fiddle:

这是我的小提琴:

http://fiddle.jshell.net/wanxe/vsa46bw8/

4 个解决方案

#1


32

This happens because your click handler fires before the value of the radio button changes. You need to listen to the change event instead:

发生这种情况是因为单击处理程序在单选按钮的值更改之前触发。你需要听取改变事件:

<input 
  type="radio" 
  name="optionsRadios" 
  id="optionsRadios2" 
  value=""
  v-model="srStatus" 
  v-on:change="foo"> //here

Also, make sure you really want to call foo() on ready... seems like maybe you don't actually want to do that.

此外,确保你真的想要准备好调用foo()...似乎你可能实际上并不想这样做。

ready:function(){
    foo();
},

更多相关文章

  1. python模拟多次采样通过低概率事件多次重复实验趋近必然事件
  2. 由ajax [duplicate]生成时,formset的提交按钮不起作用
  3. 初学者的Selenium自动化测试指南,基于Python(五)——常用键盘事件
  4. 从django视图中的按钮获取click事件
  5. Telnet套接字网关到Coldfusion事件网关,连接到Asterisk AMI
  6. 我如何在Linux和Python中监听“usb设备插入”事件?
  7. 清华大学出版社“抄袭事件”回放
  8. Inotify: 高效、实时的Linux文件系统事件监控框架
  9. mysql创建任务事件

随机推荐

  1. Android 常用的权限
  2. 探索Android该Parcel机制上
  3. Android 角标 BadgeView/android-viewbad
  4. Android(安卓)自定义View - 启航 一般Vie
  5. 2013.07.22——— android 修改hosts
  6. Android中的Handler的具体用法
  7. Android使用DialogFragment,自定义对话框
  8. android 设计模式相关内容
  9. Android(安卓)APP之间共享SharedPreferen
  10. 动态设置android:drawableLeft|Right|Top