<view class="history-text">
<!-- searchBtn(item.value) uni不支持拿 满足:元素本身循环,拿元素本身渲染的值 -->
<!-- 采用 :data-index='index' 通过e拿下标-->
<text v-for="(item,index) in searchList" :key="index" :data-index='index'
@click="searchBtn">{{item.value}}</text>
</view>
//点击历史记录数据查询
searchBtn(e) {
let num = e.currentTarget.dataset.index // 获取当前点击元素在数组中的下标
this.keyWord = this.searchList[num].value
},
searchList:[
{id:1,value:"aa"},
{id:2,value:"bb"},
{id:3,value:"cc"}
]