[英]Webpack 4 + Vue + jQuery
I have a project on jQuery, I need to transfer it to Vue. 我有一个关于jQuery的项目,我需要将其转移到Vue。
I'm assembly a project using webpack 4 and I can not find a working recipe for integrating a jQuery into a view on this version of webpack. 我正在使用webpack 4组装一个项目,但找不到将jQuery集成到此版本webpack的视图中的有效方法。
Maybe someone, can show me an example, how can this be done? 也许有人可以给我举个例子,这怎么办?
All recipes, what I can find on the internet - not work in webpack 4. I'm trying loaders, try edit config.js - nothing works. 我在互联网上可以找到的所有食谱-在webpack 4中无法使用。我正在尝试加载程序,请尝试编辑config.js-无效。
Help me, please! 请帮帮我!
Check my repo, jQuery is integrated here: https://github.com/syed-haroon/vue-cli3-starter-template 检查我的仓库,jQuery已集成在这里: https : //github.com/syed-haroon/vue-cli3-starter-template
And please make sure to install vue-cli3
may be in latest node 8
version and do npm install
and to run the project npm run serve
(now it's changed and npm run dev
will not work). 并且请确保安装vue-cli3
可能是最新的node 8
版本,并执行npm install
并运行项目npm run serve
(现在已更改,并且npm run dev
将无法工作)。
And you can use it this way: 您可以通过以下方式使用它:
<template>
<div>
<H1 class="lorem">jQuery Works</H1>
</div>
</template>
<script>
import $ from 'jquery';
export default {
mounted() {
$('.lorem').addClass('ipsum');
}
};
</script>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.