1、在html中使用 $event
应用场景:
在子组件中用 $emit 发射函数给父组件,且带有参数,在父组件中需要接收param1并新增param2
// 子组件发射fnPractice函数
this.$emit('fnPractice', param1)
// 在父组件中使用名为component的子组件
<component @fnPractice="fnPractice($event, param2)"></component>
2、在 methods中使用函数嵌套新增额外参数
应用场景:
饿了么form表单写注册页面,输入密码 firstPassWord,再次确认密码 secondPassWord 时,需要检测 firstPassWord 是否等于 secondPassWord
validator: (rule, value, callback) => this.validateSecPasswd(rule, value, callback, this.editor.form.passwd)
validateSecPasswd(rule, value, callback, checkVal) {
if (value !== checkVal) {
callback(new Error('确认密码和新密码不同'))
} else {
callback()
}
}
因篇幅问题不能全部显示,请点此查看更多更全内容