代码如下,移动端页面中有一个serach input像监听搜索键盘中的 “搜索按钮”,看了下keycode是13,但是每次按下回车,回报非法return的错误,不知道是哪里写的有问题
Uncaught SyntaxError: Illegal return statement
<form action="javascript:return true;" autocomplete="off">
<input type="search" id="search-input" :placeHolder="placeHolderComputed" :value="inputComputed" @keyup="keyupSearchInput" ref="searchInput">
</form>
keyupSearchInput(e) {
// 搜索回车键
if(e.keyCode == 13) {
const content = this.$refs.searchInput.value;
this.store.action.setNews([]);
this.store.api.submitSearch({
keyword: content,
queryType: 'edit'
});
this.store.action.toggleSuggestion(false);
// 人为失焦
this.$refs.searchInput.blur();
}
}
<form action="javascript:return true;" autocomplete="off">
这里的action
不对吧。。javascript:
后面要加语句,然后return
是放在函数体中的,而不能在其他地方使用