nuxt.js实战之引入jquery
head: { title: 'nuxt', meta: [ { charset: 'utf-8' }, { name: 'viewport', content: 'width=device-width, initial-scale=1, maximum-scale=1.0, user-scalable=0' }, { hid: 'description', name: 'description', content: 'Nuxt.js project' } ], link: [ { rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' } ], script: [ { src: 'https://cdn.bootcss.com/jquery/3.3.1/jquery.min.js' } ] }
nuxt.config.js中配置如上(有cdn的情况下适合使用这种方式)
如果没有也可以使用如下方案:
首先安装jquery
npm install jquery --save
需要用到webpack,如果没有需要安装,nxut.config.js中的配置如下:
const webpack = require('webpack')
module.exports = {
build: {
plugins: [
new webpack.ProvidePlugin({
'$': 'jquery'
})
]
},
plugins: []
}

浙公网安备 33010602011771号