unable to import jquery dependencies in vue-browerify template

我的未来我决定 提交于 2019-12-12 05:16:00

问题


I am using vue js browerify and i have installed jquery

i am using jquery as import $ from 'jquery and it works. To import anyother dependency like semantic.js or jquery.ui is it throwing errors.
I have read and tried all the related posts on stackoverflow.

when i do
import $ from 'jquery
import 'jquery-ui

it says jQuery in not defined.

i have tried the extend method. it still does not work. I also have tried to include the files on my index.html usng the <Script src> tag . and it says $ not defined.

please help.


回答1:


When using jQuery as es6 module window.jQuery won't be available to other libraries requiring window.jQuery to be set, you need to define it yourself:

import $ from 'jquery'
window.$ = window.jQuery = $

import 'jquery-ui'
import '...'


来源:https://stackoverflow.com/questions/43677351/unable-to-import-jquery-dependencies-in-vue-browerify-template

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!