laravel v-on: 无线电输入 VueJS 的更改事件

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/43771804/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 15:54:41  来源:igfitidea点击:

v-on:change event for radio input VueJS

laravelvue.js

提问by Duka

I have a problem with event listener for input radio.

我对输入无线电的事件侦听器有问题。

HTML:

HTML:

<input
  type="radio"
  id="flat"
  name="property_type"
  class="switch-input"
  v-model="registerData.propertyType"
  value="flat"
  checked
/>

And when I add v-on="change:foo"into input element, the page crash loading on that input radio.

当我添加v-on="change:foo"到输入元素时,页面在该输入无线电上加载时崩溃。

Code:

代码:

var companyList = new Vue({
    el: '#companyList',
    cache: false,
    data: {
        disabledTime: {
            to: new Date()
        },
        registerData: {
            serviceCategoryId: '{{ $serviceCategoryId }}'
        }
    },
    methods: {
        foo: function() {
            console.log('aaa');
        }
    },
})

What is the best way to call function on change event?

在更改事件上调用函数的最佳方法是什么?

回答by yazfield

Assuming you're using vuejs 2, your syntax is incorrect, this is actually vuejs 1 syntax.

假设您使用的是 vuejs 2,您的语法不正确,这实际上是 vuejs 1 的语法。

v-on:change="foo"is the correct syntax, check the docsfor more details.

v-on:change="foo"是正确的语法,请查看文档以获取更多详细信息。