vue-webpack 引入echarts 注意事项

0.执行教程 https://www.cnblogs.com/goloving/p/8654176.html
1.在index 中创建 div

<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1.0">
    <title>app</title>
  </head>
  <body>
    <div id="app"></div>
    <!-- built files will be auto injected -->
    <div id="ecarts1" style="width:200px;height:200px" ></div>

  </body>
</html>

2.在组件中引入 echarts
  

<template>

  <div>
    <HelloWorld></HelloWorld>
    <ButtonIvew></ButtonIvew>
  </div>
</template>

<script>
import HelloWorld from "./components/HelloWorld";
import ButtonIvew from "./components/button";

export default {
  components: {
    HelloWorld,
    ButtonIvew
  },
  name: "App"
};

var echarts = require("echarts");
require(‘echarts/chart/line‘);
require(‘echarts/chart/bar‘);

var option = {
  tooltip: {
      trigger: ‘axis‘
  },
  legend: {
      data: [‘蒸发量‘, ‘降水量‘]
  },
  toolbox: {
      show: true,
      feature: {
          mark: {
              show: true
          },
          dataView: {
              show: true,
              readOnly: false
          },
          magicType: {
              show: true,
              type: [‘line‘, ‘bar‘]
          },
          restore: {
              show: true
          },
          saveAsImage: {
              show: true
          }
      }
  },
  calculable: true,
  xAxis: [{
      type: ‘category‘,
      data: [‘1月‘, ‘2月‘, ‘3月‘, ‘4月‘, ‘5月‘, ‘6月‘, ‘7月‘, ‘8月‘, ‘9月‘, ‘10月‘, ‘11月‘, ‘12月‘]
  }],
  yAxis: [{
      type: ‘value‘,
      splitArea: {
          show: true
      }
  }],
  series: [{
      name: ‘蒸发量‘,
      type: ‘bar‘,
      data: [2.0, 4.9, 7.0, 23.2, 25.6, 76.7, 135.6, 162.2, 32.6, 20.0, 6.4, 3.3]
  }, {
      name: ‘降水量‘,
      type: ‘bar‘,
      data: [2.6, 5.9, 9.0, 26.4, 28.7, 70.7, 175.6, 182.2, 48.7, 18.8, 6.0, 2.3]
  }]
};
var myChart = echarts.init(document.getElementById(‘ecarts1‘));
myChart.setOption(option);

</script>

<style>
#app {
  text-align: center;
  margin: 60px;
}
</style>

  
3.在组件构建完成挂载后执行 生成echarts动作

原文地址:https://www.cnblogs.com/tongbiao/p/9380026.html

时间: 2024-08-30 10:21:43

vue-webpack 引入echarts 注意事项的相关文章

vue+webpack 引入jquery

首先cnpm install jquery:这时jquery已经安装成功,可以使用jquery,但是jquery不是全局的,需要在使用的组件中引入jquery,jquery的路径是jquery/dist/jquery.min.js, inport $ from "jquery/dist/jquery.min.js" 就可以使用$了: 我们也可以在webpack.base.config.js中配置:路径的别名方便引入: 之后我们就可以在使用jquery的组件中这样引入 import $

vue按需引入/全局引入echarts

npm install echarts -S 1.按需引入 新建echarts.js公共引入 // 文件路径 @/lib/echarts.js 自行配置 // 加载echarts,注意引入文件的路径 import echarts from 'echarts/lib/echarts' // 再引入你需要使用的图表类型,标题,提示信息等 import 'echarts/lib/chart/bar' import 'echarts/lib/component/legend' import 'echar

vue按需引入echarts

下载安装echarts包:npm install echarts -D 一.全局引入 main.js中配置 import echarts from 'echarts' //引入echarts Vue.prototype.$echarts = echarts //引入组件 缺点:如果是完整的引入Echarts,会额外的引入其他无用的配置文件,造成应用文件体积过大,资源加载耗时过长,影响用户体验 二.按需引入 如果是在许多页面中都有用到,就写在main.js中 //引入基本模板 let echart

webpack构建Vue项目引入jQ时发生“&#39;$&#39; is defined but never used”的处理

今天公司需要新建个数据后台,就按照查到的方法构建了Vue框架的项目,引入jQ.bootstrap时,按照在线方法配置,发现 main.js 里的引用jQ一直显示红标,没多想,在按照网上配置完后,npm run dev运行,就抛出这么个错误,百思不得解 错误如下: '$' is defined but never used 1 http://eslint.org/docs/rules/space-before-function-paren 1 http://eslint.org/docs/rule

VUE项目中按需引入ECharts.js

安装ECharts包 npm install echarts --save 引入 ECharts 在main.js中引入 1 // 引入 ECharts 主模块 2 let echarts = require('echarts/lib/echarts'); 3 // 引入折线图/柱状图等组件 4 require('echarts/lib/chart/line') 5 require('echarts/lib/chart/bar') 6 require('echarts/lib/chart/rad

vue+vuex+axios+echarts画一个动态更新的中国地图

一. 生成项目及安装插件 # 安装vue-cli npm install vue-cli -g # 初始化项目 vue init webpack china-map # 切到目录下 cd china-map # 安装项目依赖 npm install # 安装 vuex npm install vuex --save # 安装 axios npm install axios --save # 安装 ECharts npm install echarts --save 二. 项目结构 ├── ind

vue项目整合echarts

准备工作: 首先我们初始化一个vue项目,执行vue init webpack echart,接着我们进入初始化的项目下.安装echarts, npm install echarts -S //或  cnpm install echarts -S 安装完成之后,我们就可以开始引入我们需要的echarts了,接下来介绍几种使用echarts的方式. 1.全局引用 首先在main.js中引入echarts,将其绑定到vue原型上: import echarts from 'echarts' Vue.

Vue2.0与 [百度地图] 结合使用———vue+webpack+axios+百度地图实现组件之间的通信

Vue2.0与 [百度地图] 结合使用: 1.vue init webpack-simple vue-baidu-map 2.下载axios cnpm install axios; 3.在main.js中引入axios,并使用 import axios from 'axios' /* 把axios对象挂到Vue实例上面,其他组件在使用axios的时候直接 this.$http就可以了 */ Vue.prototype.$http = axios; 4.引入百度地图的js秘钥--->最好在inde

非常简单的vue里面引入jquery

如何在vue里面引入jq了,只需四部就完成 第一步 cnpm install jquery 第二步 打开build文件夹 , 打开webpack.base.conf.js文件找到下面module.exports module.exports = { resolve: { alias: { 'jquery':path.resolve(__dirname,'../node_modules/jquery/src/jquery') //添加这段代码 } }, 第三步 还是在build文件夹,打开webp