vue 引用第三方JQ插件

是这样的,有时候在开发的过程中,不得不使用JQ插件,但是如果直接在index.html上引入的话不仅没有生效且报错。

正确的引入方式如下:

第一步:在utlis文件下新建 jquery.js 

//jquery.js

import $ from 'jquery';
window.$ = $;
window.jQuery = $;
export default $;

第二步:在要使用插件的页面中引入文件:

<script>
    import $ from './utils/jquery.js'
    import './utils/jquery.Jcrop.js'
    import qs from 'qs';
    export default {
            ......  
        }
</script>

 

posted @ 2021-02-02 10:14  秃头的铲屎官  Views(367)  Comments(0Edit  收藏  举报