vue 趋势图组件动态渲染问题

牛Kǎi牛牛牛� 2020-05-20 04:20:43
写了一个趋势图组件但是在页面上写该标签渲染不出来了 大佬帮我看看是怎么回事吗

这是在home页面上的标签


这是趋势图文件代码
<template>
<!--为echarts准备一个具备大小的容器dom-->
<div id="main" style="width: 600px;height: 400px;"></div>
</template>
<script>
import echarts from 'echarts'
import { defineComponent} from '@vue/composition-api'
export default defineComponent({
name: '',
props:{
legendData: Array,
firstList: Array,
firstColor: String,
secondColor: String,
secondList: Array,
},
data() {
return {
charts: '',
/* opinion: ["1", "3", "3", "4", "5"],*/
opinionData: ["3", "2", "4", "4", "5"],
Datas: ["2", "2", "4", "5", "4"]
}
},
methods: {
drawLine(id) {
this.charts = echarts.init(document.getElementById(id))
this.charts.setOption({
tooltip: {
trigger: 'axis'
},
legend: {
data: legendData
},
grid: {
left: '3%',
right: '4%',
bottom: '3%',
containLabel: true
},

toolbox: {
feature: {
saveAsImage: {}
}
},
xAxis: {
type: 'category',
boundaryGap: false,
data: ["1","2","3","4","5"]

},
yAxis: {
type: 'value'
},

series: [
{
name: legendData[0],
type: 'line',
stack: '总量',
data: this.opinionData
},
{
name: legendData[1],
type: 'line',
stack: '总量',
// itemStyle: {
// normal: {
// color: secondColor,
// lineStyle: {
// color: secondColor
// }
// }
// },
data: this.Datas
}
]
})
}
},
//调用
mounted() {
this.$nextTick(function() {
this.drawLine('main')
})
}
})
</script>
<style scoped>
* {
margin: 0;
padding: 0;
list-style: none;
}
</style>
...全文
206 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
lllomh 2020-05-21
  • 打赏
  • 举报
回复
你首先看看 你 子组件内 是否有获取到这传过去的值先
「已注销」 2020-05-20
  • 打赏
  • 举报
回复
这也看不出来什么,可以试试逐步排查法,顺藤摸瓜

39,083

社区成员

发帖
与我相关
我的任务
社区描述
HTML5是构建Web内容的一种语言描述方式。HTML5是互联网的下一代标准,是构建以及呈现互联网内容的一种语言方式.被认为是互联网的核心技术之一。
社区管理员
  • HTML5社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧