Vue 使用van-search和监听@Watch实现搜索

van-search:在输入框输入数据,当在PC端点击回车开始搜索,在手机端点击输入法中的搜索开始搜索,

@Watch:主要用于当点击取消或删除输入框中的数据监听数据的变化

.vue

<van-search

v-model="keywordSubordinate"

placeholder="请输入搜索关键词"

@search="querySubordinateList"

/>

.ts

private keywordSubordinate = "";

@Watch("keywordSubordinate")

onkeywordSubordinateChanged(newVal: string, oldVal: string) {

if (!newVal || newVal === "") {   //当输入框为空时

this.querySubordinateList();

}

}

private querySubordinateList() {

}

猜你喜欢

转载自blog.csdn.net/qq_34607371/article/details/86082607