vue js 切换函数,基于三元函数

vue js toggle the function , based on ternary function

如何切换我想传递给@click 事件的功能? 这似乎合乎逻辑,但行不通。

     <v-btn  @click="(this.name==='new') ? lookup: save" > <v-btn>

我建议只创建一个函数来检查名称并从中调用函数,而不是在@click 中进行检查。也许,我还没有尝试过,如果你做 @click="() => { (this.name==='new') ? lookup() : save()};" 或只是 @click="(this.name==='new') ? lookup() : save();",它会起作用,可能不需要箭头函数。

<v-btn  @click="functionToRun" > <v-btn>

methods : 
      functionToRun(){
      (this.name==='new') ? this.lookup(): this.save();
     }//end funtionToRun