开发者社区> 问答> 正文

VUE 中如何导入echarts??报错

我在网上下载的那些echarts.js的文件导入js后各种报错。。。那位大佬分享一下?echrats的js。感谢

展开
收起
爱吃鱼的程序员 2020-06-05 15:34:59 767 0
1 条回答
写回答
取消 提交回答
  • https://developer.aliyun.com/profile/5yerqm5bn5yqg?spm=a2c6h.12873639.0.0.6eae304abcjaIB
                        <p>vue中不需要你单独下echarts.js的文件呢。</p> 
    

    1.npm install echarts --save 
    把模块导入你的工程

    2.

    <template>
      <div :style="{height:'350px',width:'100%'}" ref="myEchart"></div>
    </template>
    import echarts from 'echarts'
      export default {
        data() {
          return {
            options: {
              xAxis: {
                type: 'category',
                data: [1,2]
              },
              yAxis: {
                type: 'value'
              },
              tooltip: {
                trigger: 'axis'
              },
              series: [{
                data: [1,2],
                type: 'line'
              }]
            },
          }
        },
        mounted:{
          echarts.init(this.$refs.myEchart)
        }
      }
    2020-06-05 15:35:14
    赞同 展开评论 打赏
问答排行榜
最热
最新

相关电子书

更多
Vue.js 在前端服务化上的探索与实践 立即下载
利用编译将 Vue 组件转成 React 组件 立即下载
Vue.js在前端服务化上的实践与探索 立即下载