vue input回车执行
// v-model实现表单数据searchKeyword的双向绑定// @keydown.enter表示回车执行saveKeyWord方法<input type="text" v-model="searchKeyword" :placeholder="placeholder" @keydown.enter="saveKeyWord">data:function () {return
·
// v-model实现表单数据searchKeyword的双向绑定
// @keydown.enter表示回车执行saveKeyWord方法
<input type="text" v-model="searchKeyword" :placeholder="placeholder" @keydown.enter="saveKeyWord">
data:function () {
return {
searchKeyword:'',
}
},
methods:{
saveKeyWord:async function () {
// 在localStorage保存搜索词
this.keywordList.push(this.searchKeyword);
localStorage.keywordList = JSON.stringify(this.keywordList);
// 利用api搜索音乐
let result = await searchMusic(this.searchKeyword);
this.searchSongs = result.data.result.songs;
console.log(this.searchSongs)
},
更多推荐
已为社区贡献8条内容
所有评论(0)