无法在vue-browerify模板中导入jQuery依赖项 [英] unable to import jquery dependencies in vue-browerify template

查看:86
本文介绍了无法在vue-browerify模板中导入jQuery依赖项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用vue js browify ,并且我已经安装了jquery

I am using vue js browerify and i have installed jquery

我正在将jquery用作import $ from 'jquery,它可以正常工作. 要导入任何其他依赖项,例如semantic.jsjquery.ui,会抛出错误.
我已经阅读并尝试了关于stackoverflow的所有相关文章.

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.

我什么时候做
import $ from 'jquery
import 'jquery-ui

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

它说jQuery未定义.

it says jQuery in not defined.

我尝试了extend方法.它仍然无法正常工作. 我还尝试过使用<Script src>标签将文件包含在我的index.html中.并说$未定义.

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.

请帮助.

推荐答案

在将jQuery用作es6模块时,window.jQuery对于其他需要设置window.jQuery的库不可用,您需要自己定义它:

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 '...'

这篇关于无法在vue-browerify模板中导入jQuery依赖项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆