【问题标题】:Add additional argument for emit events - Quasar为发出事件添加附加参数 - Quasar
【发布时间】:2020-03-25 08:14:46
【问题描述】:

我正在使用 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)? 
...
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)
  }
}
...

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

【问题讨论】:

    标签: node.js vue.js quasar-framework


    【解决方案1】:

    你可以做到这一点。

    例子-

    @filter="(val,update,abort) => yourFilterFn(val,update,abort,yourCustomParam)"
    
    
    
    @save="(newValue, initialValue) => yourFilterFn(newValue,initialValue,third_argument)"
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多