应用场景:
现在很多app都有搜索功能 今天我们就用vue实现简单搜索功能:
代码如下:
<!-- 头部搜索框 -->
<div class="header">
<van-search
v-model.trim="kw"
show-action
placeholder="电池"
shape="round"
autofocus
@input="handleInput"
@keydown.enter="enter"
@keydown.up="up"
@keydown.down="down"
>
<template #left>
<van-icon name="arrow-left" />
</template>
<template #action>
<van-button type="danger" size="mini">搜索</van-button>
</template>
</van-search>
</div>
<!-- 搜索历史 -->
<div class="search-history">
<p class="recent">
<span>最近搜索</span>
<span>
<van-icon name="delete" @click="del"></van-icon>
</span>
</p>
<div class="history">
<div class=