vue中使用jQuery

1、 npm install jquery --save

2、在webpack.base.config.js中添加

module.exports = {
context: path.resolve(__dirname, '../'),
entry: {
app: './src/main.js'
},
......
plugins: [
    new webpack.ProvidePlugin({
        jQuery: "jquery",
        jquery:"jquery",
        $: "jquery",
       “window.jQuery”:"jquery"
    })
]
}

3、若有eslint检查,在.eslint.js中的module.export中添加

env: { 
// 原有
browser: true, 
// 添加 
jquery: true
}

4、在main.js中导入jQuery

import 'jquery'

猜你喜欢

转载自blog.csdn.net/przlovecsdn/article/details/81509884