热门推荐词出不来
<template>
<div class="hot">
<h4 class="hot-title">热门搜索</h4>
<div class="loading-container" v-if="!hots.length">
<me-loading/>
</div>
<ul class="hot-list" v-else>
<li
class="hot-item"
v-for="(item, index) in hots"
:key="index"
>{{item.hotWord}}</li>
</ul>
</div>
</template>
<script>
import MeLoading from 'base/loading';
import {getSearchHotKeyword} from 'api/search';
// import {searchMixin} from 'assets/js/mixins';
export default {
name: 'SearchHot',
components: {
MeLoading
},
// mixins: [searchMixin],
created() {
this.getHotKeyword().then(() => {
this.$emit('loaded');
});
},
data() {
return {
hots: []
};
},
methods: {
getHotKeyword() {
return getSearchHotKeyword().then(data => {
return new Promise(resolve => {
if (data) {
this.hots = data;
resolve();
}
});
});
}
}
};
</script>
<style lang="scss" scoped>
@import "../../assets/scss/mixins";
.hot {
padding-left: 10px;
background-color: #fff;
border-bottom: 1px solid $border-color;
margin-bottom: 10px;
&-title {
height: 34px;
line-height: 34px;
font-size: $font-size-l;
font-weight: bold;
}
&-list {
display: flex;
flex-wrap: wrap;
}
&-item {
padding: 8px;
background-color: #f0f2f5;
border-radius: 4px;
margin: 0 10px 10px 0;
color: #686868;
}
}
.loading-container {
padding: 10px 0;
}
</style>
正在回答 回答被采纳积分+1
- 参与学习 人
- 提交作业 239 份
- 解答问题 10739 个
本阶段带你深入前端开发的肌理,通过ES6基础知识和前端主流高级框架的学习,助你快速构建企业级移动webAPP应用,进入职场的终极battle
了解课程
恭喜解决一个难题,获得1积分~
来为老师/同学的回答评分吧
0 星