1)、新建webpack.config.js或直接更改bulid目录下的webpack.config.js,更改配置
module.exports = {
entry: {
app: './src/main.js'
},
externals: {
"AMap": "AMap",
}
}
2)在assets目录下新建remoteload.js
export default function remoteLoad(url, hasCallback) {
return createScript(url)
/**
* 创建script
* @param url
* @returns {Promise}
*/
function createScript(url) {
var scriptElement = document.createElement('script')
document.body.appendChild(scriptElement)
var promise = new Promise((resolve, reject) => {
scriptElement.addEventListener('load', e => {
removeScript(scriptElement)
if (