我试图不向需要参数的方法传递任何参数。到目前为止我有这个,但我似乎无法让它工作:
// 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");
}
}
最佳答案
尝试使用 search() 而不是搜索
<el-button @click:search()>Button 1</el-button>
即使你还没有关闭 if
括号
关于javascript - 不向需要参数的方法传递参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46475915/