.echarts全局样式没生效,需要在bottomView组件重写 .echarts的 width: 100%;属性
来源:6-10 搜索关键词组件开发(上)

喵咪老师
2020-11-07
想知道.echarts全局的样式 宽度属性为啥没生效?.. 已经在main.js引入了
.echarts全局样式没生效,需要在bottomView组件重写 .echarts的 width: 100%;属性
在bottomView组件加了 .echarts的 width: 100%;才显示正常.
<template>
<div class="bottom-view">
<div class="view">
<el-card shadow="hover">
<template v-slot:header>
<div class="title-wrapper">关键词搜索</div>
</template>
<template>
<div class="chart-wrapper">
<div class="chart-inner">
<div class="chart">
<div class="chart-title">搜索用户数</div>
<div class="chart-data">93,634</div>
<v-chart :options="searchUserOption" />
</div>
<div class="chart">
<div class="chart-title">搜索量</div>
<div class="chart-data">198,732</div>
<v-chart :options="searchUserOption" />
</div>
</div>
<div class="table-wrapper">
<el-table :data="tableData">
<el-table-column></el-table-column>
</el-table>
<el-pagination />
</div>
</div>
</template>
</el-card>
</div>
<div class="view">
<el-card shadow="hover">
<template v-slot:header>
<div class="title-wrapper">
<div class="title">分类销售排行</div>
<div class="radio-wrapper">
<el-radio-group v-model="radioSelect" size="small">
<el-radio-button label="品类"></el-radio-button>
<el-radio-button label="商品"></el-radio-button>
</el-radio-group>
</div>
</div>
</template>
<template>
<v-chart :options="categoryOption"></v-chart>
</template>
</el-card>
</div>
</div>
</template>
<script>
export default {
name: 'index',
data () {
return {
searchUserOption: {
xAxis: {
type: 'category',
boundaryGap: false
},
yAxis: {
type: 'value',
show: false
},
series: [{
type: 'line',
areaStyle: {
color: 'rgba(95,187,255,.5)'
},
data: [100, 150, 200, 250, 200, 150, 100, 50, 100, 150],
lineStyle: {
color: 'rgba(95,187,255,.5)'
},
itemStyle: {
opacity: 0
},
smooth: true
}],
grid: {
top: 0,
right: 0,
bottom: 0,
left: 0
}
},
searchNumberOption: {},
// 表格数据
tableData: [],
radioSelect: '品类',
categoryOption: {}
}
}
}
</script>
<style lang="scss" scoped>
.bottom-view {
display: flex;
margin-top: 20px;
.view {
flex: 1;
width: 50%;
box-sizing: border-box;
// 第一个view元素
&:first-child {
padding: 0 10px 0 0;
}
// 第二个view元素
&:last-child {
padding: 0 0 0 10px;
}
.title-wrapper {
display: flex;
align-items: center;
height: 60px;
box-sizing: border-box;
border-bottom: 1px solid #eee;
font-size: 14px;
font-weight: 500;
padding: 0 0 0 20px;
.radio-wrapper {
flex: 1;
display: flex;
justify-content: flex-end;
padding-right: 20px;
}
}
.chart-wrapper {
display: flex;
flex-direction: column;
height: 452px;
.chart-inner {
display: flex;
padding: 0 10px;
margin-top: 20px;
.chart {
flex: 1;
// 上下填充0 左右填充10px
padding: 0 10px;
.chart-title {
color: #999;
font-size: 14px;
}
.chart-data {
font-size: 22px;
color: #333;
font-weight: 500;
// 字符间距
letter-spacing: 2px;
}
.echarts {
height: 50px;
width: 100%;
}
}
}
.table-wrapper {
flex: 1;
margin-top: 20px;
padding: 0 20px 20px;
.el-pagination {
display: flex;
justify-content: flex-end;
margin-top: 15px;
}
}
}
}
}
</style>
写回答
1回答
-
扬_灵
2020-11-07
同学你好,你可以通过控制台看一下echarts的样式是否被覆盖了,如果被赋给了可以在样式文件中使用important提升样式优先级。
00
相似问题