为发出事件添加附加参数 - Quasar

kee*_*han 3 node.js vue.js quasar-framework

我正在使用 Quasar 框架。并想在框架组件的预设上添加第三个参数。


这是针对Q-popup-editsave/cancel事件:

句法:

@save->function(value, initialValue)

描述

当值已成功验证且应保存时发出

参数:

value- 要保存的验证值

initialValue- 更改前的初始值


有没有办法让我不必指定“新”和“旧”值而只需传递第三个参数? @save="saved(.., .., arg3)"或类似的东西@cancel="canceled(arg3)"。如果这是不可能的,那么我如何传递初始值和新值?

<q-popup-edit buttons lazy-rule v-model="props.row.value" @save=(newValue, initialValue, arg3)? 
Run Code Online (Sandbox Code Playgroud)
...
methods: {
  saved (val, initialValue, arg3) {
    console.log(`original value = ${initialValue}, new value = ${val}`)
    console.log('argument3 = ' + arg3)
  },
  canceled (val, initialValue, arg3) {
    console.log(`retain original value = ${initialValue}, canceled value = ${val}`)  
    console.log('argument3 = ' + arg3)
  }
}
...
Run Code Online (Sandbox Code Playgroud)

Quasar Q-popup-edit 文档: https://quasar.dev/vue-components/popup-edit

Pat*_*tik 5

你可以实现这一点。

例子 -

@filter="(val,update,abort) => yourFilterFn(val,update,abort,yourCustomParam)"



@save="(newValue, initialValue) => yourFilterFn(newValue,initialValue,third_argument)"
Run Code Online (Sandbox Code Playgroud)