无法滚动的问题
来源:1-2 内容组件--数据获取和显示
Mcziw
2020-02-08 00:34:56
老师,您好,我是跟着课程老师来写代码的,写完发现分类页左边的tab和右边的content内容均不能滚动,在浏览器下查看,swiper也是有获得高度的,请教老师,这是什么原因导致的呢?代码如下:
category下的tab:
<template>
<me-scroll :scrollbar="false">
<ul class="tab">
<li
class="tab-item"
:class="{'tab-item-active': item.id === curId}"
v-for="(item,index) in items"
:key="index"
@click="switchTab(item.id)"
>{{item.name}}</li>
</ul>
</me-scroll>
</template>
<script>
import MeScroll from 'base/scroll';
import {categoryNames} from "./config";
export default {
name: "CategoryTab",
components: {
MeScroll
},
data() {
return {
curId: ''
}
},
created() {
this.init();
this.switchTab(this.items[0].id);
},
methods: {
init() {
this.items = categoryNames;
},
switchTab(id) {
if (this.curId === id) {
return;
}
this.curId = id;
this.$emit('switch-tab',id);
}
}
};
</script>
<style lang="scss" scoped>
@import "~assets/scss/mixins";
$tab-item-height: 46px;
.tab {
width: 100%;
&-item {
height: $tab-item-height;
background-color: #fff;
border-right: 1px solid $border-color;
border-bottom: 1px solid $border-color;
color: #080808;
font-size: $font-size-l;
font-weight: bold;
text-align: center;
line-height: $tab-item-height;
@include ellipsis();
&:last-child {
border-bottom: none;
}
}
&-item-active {
background: none;
border-right: none;
color: #f23030;
}
}
</style>
category下的index:
<template>
<div class="category">
<header class="g-header-container">
<category-header/>
</header>
<div class="g-content-container">
<div class="sidebar">
<category-tab @switch-tab="getCurrentId"/>
</div>
<div class="main">
<category-content :curId="curId"/>
</div>
</div>
</div>
</template>
<script>
import CategoryHeader from './header';
import CategoryTab from './tab';
import CategoryContent from './content';
export default {
name: "Category",
components: {
CategoryHeader,
CategoryTab,
CategoryContent
},
data() {
return {
curId: ''
};
},
methods: {
getCurrentId(id) {
this.curId = id;
}
}
};
</script>
<style lang="scss" scoped>
@import "~assets/scss/mixins";
.category {
overflow: hidden;
width: 100%;
height: 100%;
background-color: $bgc-theme;
padding-top: 50px;
}
.g-content-container {
display: flex;
}
.sidebar {
width: 80px;
height: 100%;
}
.main {
flex: 1;
height: 100%;
}
</style>
2回答
好帮手慕夭夭
2020-02-08
同学你好,因为没有同学完整的项目,所以把同学上传的代码放在源码中测试会有偏差。请同学重新创建一个新问题,把全部代码都粘贴到问答区(如果代码太多,可以在回复区域继续粘贴),以便老师更加准确的为你测试。
祝学习愉快 !
好帮手慕夭夭
2020-02-08
同学你好,老师把你的代码放在源码中测试是可以滚动的,如下:
同学是不是测试时没有保存,保存后刷新页面试一试。如果我的回答帮助到了你,欢迎采纳,祝学习愉快~
相似问题