我正在尝试不将参数传递给需要参数的方法。到目前为止我有这个,但我似乎无法让它工作:
// HTML
// this one doesn't pass an argument
<el-button @click:search>Button 1</el-button>
// this one does pass an argument
<el-button @click:search('hey')>Button 2</el-button>
// JS
method: {
search (searchBy) {
// if there's a value
if( searchBy ) {
console.log(searchBy);
// if there's no value output this intead
else
console.log("nothing to search by");
}
}
答案 0 :(得分:2)
尝试搜索()而不是搜索
<el-button @click:search()>Button 1</el-button>
即使您尚未关闭if
括号