前端 vue 3.0 版怎么配置引用 高德地图
找了很多资料 都是2.0版本的配置,3.0的配置是在vue.config.js 下配置 但是具体的配置还是不知道编写
-
2019-01-09
vue-cli 3.0+ API文档: a(https://cli.vuejs.org/zh/guide/webpack.html#%E9%93%BE%E5%BC%8F%E6%93%8D%E4%BD%9C-%E9%AB%98%E7%BA%A7)[https://cli.vuejs.org/zh/guide/webpack.html#%E9%93%BE%E5%BC%8F%E6%93%8D%E4%BD%9C-%E9%AB%98%E7%BA%A7]
具体引入使用jQuery demo:
1. index.html文件中添加<script src="https://cdn.bootcss.com/jquery/3.3.1/jquery.min.js"></script>
2. vue.config.js文件中添加
[pre]
chainWebpack: config => {
config.externals({
jquery: 'jQuery'
})
const svgRule = config.module.rule('svg')
svgRule.uses.clear()
svgRule
.test(/\.svg$/)
.use('svg-sprite-loader')
.loader('svg-sprite-loader')
},
[/pre]
img[//cdn.renren.io/eca6c201901091641572498.png]
3. 在app.vue中测试添加代码:
[pre]
import jquery from 'jquery'
...
// 在任意地方调用
console.log(jquery)
[/pre]