zoukankan      html  css  js  c++  java
  • vue-echarts在vue中的使用

    安装依赖:

    【win】npm install echarts vue-echarts
    【mac】sudo npm install echarts vue-echarts

    Vue-ECharts 默认在 webpack 环境下会引入未编译的源码版本,Vue CLI 创建项目可能会遇到默认配置把 node_modules 中的文件排除在 Babel 转译范围以外的问题。
    修复方法是在vue.config.js中添加如下代码:

    1 // For Vue CLI 3+, add vue-echarts and resize-detector into transpileDependencies in vue.config.js like this:
    2 transpileDependencies: [
    3     'vue-echarts',
    4     'resize-detector'
    5 ]


    引入:

    import ECharts from 'vue-echarts'

    各零件按需加载,手动引入 ECharts 各模块来减小打包体积:

    import "echarts/lib/chart/line"; // 线图
    import "echarts/lib/chart/bar"; // 柱图
    import 'echarts/lib/component/legend' // 图例
    import 'echarts/lib/component/tooltip' //提示框

    etc...

    注册:

    Vue.component('myEchart', ECharts)

    使用组件:

    <myEchart :options="echartsOptions" ref="myCharts" />

    vue-echarts的options设置基本同echarts,配置文档看echarts官网即可。

  • 相关阅读:
    bzoj1297 [SCOI2009]迷路
    bzoj1085 [SCOI2005]骑士精神
    bzoj1009 [HNOI2008]GT考试
    uoj#73 【WC2015】未来程序
    bzoj1016 [JSOI2008]最小生成树计数
    bzoj2818 Gcd
    python递归——汉诺塔
    python参数
    python函数
    为什么会出现__pycache__文件夹?
  • 原文地址:https://www.cnblogs.com/padding1015/p/11611600.html
Copyright © 2011-2022 走看看