How do Webpack+Vue import third party plug ins for Jquery and Jquery

  • 2021-07-22 08:50:52
  • OfStack

Create 1 jquery-vendor. js file


import $ from 'jQuery';
console.log($);
window.$ = $;
window.jQuery = $;
export default $;

Import JQuery and assign it to the window object as a global variable.

Make the following reference in vue component


import $ from './assets/jquery-v';
import 'bootstrap-material-design'; 
// Call initialization 
$(function(){
 $.material.init();
});

Note:

1. Can only be referenced in components of vue

2. If the introduction of jquery. js in main. js is Ok, there is a problem in this case with the introduction of a third-party plug-in of jquery either in mian. js or in an vue component.


Related articles: