1.首选通过npm安装jquery?
2.在build/webpack.base.conf文件当中引入jquery
<pre>module.exports = {
...
resolve: {
extensions: ['.js', '.vue', '.json'],
alias: {
'vue$': 'vue/dist/vue.esm.js',
'@': resolve('src'),
'jquery': path.resolve(__dirname, '../node_modules/jquery/src/jquery')
}
},
...
}</pre>
3.在需要的地方
import $ from 'jquery' export default { name: 'hello', data () { return { msg: 'Welcome to Your Vue.js App' } }, mounted:function(){ let test = $('#test').text() console.log(test) }, methods:{ } }