vue.js和外部jquery库

时间:2017-01-30 06:09:34

标签: laravel vue.js

我在Laravel上使用Vue js 2进行了项目。 我创建了组件Card.vue,我想使用jquery文件上传插件 - https://github.com/blueimp/jQuery-File-Upload/wiki/Basic-plugin

因为我需要连接3个js文件

~/condaexpts$ virtualenv -p python3 venv
Running virtualenv with interpreter /usr/bin/python3
Using base prefix '/usr'
New python executable in venv/bin/python3
Also creating executable in venv/bin/python
Installing setuptools, pip...done.

~/condaexpts$ source venv/bin/activate

(venv)~/condaexpts$ python --version
Python 3.4.3

(venv)~/condaexpts$ python $WORKDIR/python/pyspark/sql/tests.py                                                                                                                                      
Traceback (most recent call last):
  File "/home/ubuntu/condaexpts/spark-2.1.0-bin-hadoop2.7/python/pyspark/sql/tests.py", line 26, in <module>
    import pydoc
  File "/usr/lib/python3.4/pydoc.py", line 59, in <module>
    import importlib._bootstrap
  File "/home/ubuntu/condaexpts/venv/lib/python3.4/importlib/__init__.py", line 40, in <module>
    import types
  File "/home/ubuntu/condaexpts/spark-2.1.0-bin-hadoop2.7/python/pyspark/sql/types.py", line 22, in <module>
    import calendar
  File "/usr/lib/python3.4/calendar.py", line 10, in <module>
    import locale as _locale
  File "/home/ubuntu/condaexpts/venv/lib/python3.4/locale.py", line 20, in <module>
    import functools
  File "/home/ubuntu/condaexpts/venv/lib/python3.4/functools.py", line 22, in <module>
    from types import MappingProxyType
ImportError: cannot import name 'MappingProxyType'

我尝试在主页的页脚,组件中连接这些文件,但它不起作用。 你能帮我吗 - 我如何用vue js组件连接外部jquery库? 感谢

1 个答案:

答案 0 :(得分:0)

我会尝试使用npm模块来为这种情况加载jquery插件。 https://www.npmjs.com/package/blueimp-file-upload。 如果您有webpack设置,那么您可以通过ProvidePlugins加载jquery npm install jquery然后将它放在你的webpack配置

plugins:[ new webpack.ProvidePlugin({ $: "jquery", jQuery:'jquery', jquery:'jquery' }), ], 我不知道browserify的设置,但这里的想法是通过npm使用这些插件,因为它更可靠。我有一个与jquery fullcalendar类似的情况,并设法通过安装适当的npm库来使其工作。

顺便说一句,您可以指定您获得的错误或至少更多细节吗?