searchHistory.vue
1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
<template>
<div class="search-history-com" v-if="searchHistoryArr.length">
<div class="title">历史搜索</div>
<div class="box">
<div class="list-box">
<div class="item" v-for="(item, index) in searchHistoryArr" :key="index" @click="jump(item)">
<div class="text">{{item}}</div>
</div>
</div>
<div class="line"></div>
<div class="buttons-box">
<div class="btn btn-primary" @click="clear">清除搜索历史</div>
</div>
</div>
</div>
</template>
<script>
export default {
data: function () {
return {
}
},
props: ["searchHistoryArr"],
methods: {
/**
* 点击跳转
* @param {object} item [数据对象]
*/
jump(item) {
this.$emit("jump", item);
},
/**
* 清除搜索历史
*/
clear(item) {
this.$emit("clear");
}
}
}
</script>
<!-- Add "scoped" attribute to limit CSS to this component only -->
<style rel="stylesheet/less" lang="less" scoped>
@import './searchHistory';
</style>