1.npm 下载一个4.9.0版本的echarts,如果下的版本过高,没有地图的json数据
2.在main.js里引入echarts
import Vue from 'vue'
import App from './App'
import router from './router'
import ElementUI from 'element-ui'
import echarts from 'echarts'
import china from 'echarts/map/json/china.json'
echarts.registerMap('china',china)
// const map=require('./view/js/map');
Vue.config.productionTip = false
Vue.prototype.$echarts = echarts
Vue.use(ElementUI);
/* eslint-disable no-new */
new Vue({
el: '#app',
router,
components: { App },
template: '<App/>'
})
3.在你需要的界面里引入china.json
require(“echarts/map/json/china.json”);
4.完善代码
drawLine() {
var myChartContainer = document.getElementById("myChartChina");
var resizeMyChartContainer = function () {
myChartContainer.style.width = 100 + "%";