这里是引入全局的jQuery
1.在package.json文件中,‘devDependencies’对象中添加”jquery”: “^3.1.1”,
2.在build文件夹下的webpack.base.conf.js文件中添加:

var webpack = require("webpack")
// 增加一个plugins
   plugins: [
      new webpack.optimize.CommonsChunkPlugin('common.js'),
      new webpack.ProvidePlugin({
          jQuery: "jquery",
          $: "jquery"
      })

   ],

3.vue文件中使用:

//这里不用引入jQuery了,已经是全局的了
<script src="/static/js/easydialog.min.js" ></script>
<script src="/static/js/wx-mobile.js"></script>
<script>

    document.onreadystatechange = function(){
    if(document.readyState=="complete"){
        $(".hhide").show();
        var liH=$('#first-li1').outerWidth();
        $('#index-main').children('ul').css('height',liH);
   }
}


export default {
  name: 'MainPage',
  data () {
    return {
     // msg: 'Welcome to Your Vue.js App'
    }
  }
}
</script>
Logo

前往低代码交流专区

更多推荐