vue中使用echarts和百度地图

1.在public/index.html中添加以下代码

2.在vue.config.js中添加配置
`module.exports = {

publicPath: './',
outputDir: 'dist',
assetsDir: 'static',
indexPath: 'index.html',
productionSourceMap: false,
configureWebpack: {
    externals: {
        'BMap': 'BMap',
        'BMap_Symbol_SHAPE_POINT':'BMap_Symbol_SHAPE_POINT'
    }
},

}`
3.最后在vue文件中引入
import BMap from 'BMap
require('echarts/extension/bmap/bmap')
4.完成,下面是echarts代码

  let option = {
    bmap: {
        center: [-73.98, 40.76],
        zoom: 13,
        roam: true,
        mapStyle: {style:'grayscale'}
    },

    series: [{
        type: 'scatter',
        coordinateSystem: 'bmap',
        data: data,
    }]
  }
  map.setOption(option)`

你可能感兴趣的:(vue.js)