1、安装cesium
npm install cesium
2、在vue.config.js加入如下
const cesiumSource = 'node_modules/cesium/Source';
const cesiumWorkers = '../Build/Cesium/Workers'
modele.exports={
configureWebpack:{
resolve: {
alias: {
'@': resolve('src'),
'cesium': path.resolve(__dirname, cesiumSource)
}
},
plugins:[
new CopyWebpackPlugin([{ from: path.join(cesiumSource, cesiumWorkers), to: 'Workers' }]),
new CopyWebpackPlugin([{ from: path.join(cesiumSource, 'Assets'), to: 'Assets' }]),
new CopyWebpackPlugin([{ from: path.join(cesiumSource, 'Widgets'), to: 'Widgets' }]),
new CopyWebpackPlugin([{ from: path.join(cesiumSource, 'ThirdParty/Workers'), to: 'ThirdParty/Workers' }]),
new webpack.DefinePlugin({
//此处路径要注意!!根据自己的资源路径
CESIUM_BASE_URL: JSON.stringify('../')
})
],
amd:{
toUrlUndefined:true
},
module: {
unknownContextCritical: false,
unknownContextRegExp:/\/cesium\/cesium\/Source\/Core\/buildModuleUrl\.js/,
}
}
}
3、引入
var Cesium = require('cesium/Cesium');
var widgets= require('cesium/Widgets/widgets.css');
Vue.prototype.Cesium = Cesium;
Vue.prototype.widgets = widgets
|