热门推荐问题
<template>
<div class="hot">
<div class="hot-title">
<h4>热门推荐</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>
</div>
</template>
<script>
import MeLoading from "base/loading";
import {getSearchHotKeyword} from "api/search"
export default {
name: "SearchHot",
components: {
MeLoading
},
data(){
return{
hots:[]
};
},
created(){
this.getHotKeyword().then(()=>{
this.$emit('loaded');
})
},
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>
------------------------------------
<template>
<transition name="search">
<div class="search">
<header class="g-header-container">
<search-header/>
</header>
<div class="g-content-container">
<me-scroll ref="scroll">
<search-hot></search-hot>
</me-scroll>
</div>
</div>
</transition>
</template>
<script>
import SearchHeader from "./header";
import SearchHot from "./hot";
import MeScroll from "base/scroll"
export default {
name: "Search",
components:{
SearchHeader,
SearchHot,
MeScroll
}
}
</script>
<style lang="scss" scoped>
@import "~assets/scss/mixins";
.search {
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
z-index: $search-z-index;
background-color: $bgc-theme;
}
.search-enter-active,
.search-leave-active {
transition: all 0.3s;
}
.search-enter,
.search-leave-to {
transform: translate3d(100%, 0, 0);
}
</style>
1。引入滚动条之后热门推荐就不显示
2。没有滚动条的时候,
正在回答
同学你好,使用同学提供的部分代码,放到源码中进行测试,“热门推荐”是显示的哦。
如下图:
同学的不能显示,是否是其他代码书写的有问题,建议如下排查
看下类名为g-content-container的元素是否设置padding-top,如果没有的话,建议添加,如下:
如果帮助到了你,欢迎采纳~祝学习愉快~
- 参与学习 人
- 提交作业 239 份
- 解答问题 10739 个
本阶段带你深入前端开发的肌理,通过ES6基础知识和前端主流高级框架的学习,助你快速构建企业级移动webAPP应用,进入职场的终极battle
了解课程
恭喜解决一个难题,获得1积分~
来为老师/同学的回答评分吧
0 星