【发布时间】:2018-04-09 09:12:51
【问题描述】:
我的组件中有这个:
template: <input @blur="$emit('customEvent', arg1)" v-model="arg1">
这在我的 html 模板中:
<component @customEvent="method1(arg2)"></component>
我需要为method1() 函数提供一个参数(arg2),但我还需要从$emit() 获取arg1。
我试过这个(进入 Vue 实例):
method1(arg2, arg1) {
console.log("This is the arg2: " + arg2);
console.log("This is the arg1: " + arg1);
}
当然,我试图扭转它们,但不起作用,arg1 没有被通过,而是被替换了。
我知道它必须有一个命名空间(可能类似于arg1=arg1),但我还没有找到类似的东西。
【问题讨论】:
-
这是否是父子组件通信。
-
我想知道这是否可行。
标签: javascript vue.js vuejs2