Skip to content
This repository has been archived by the owner on Oct 4, 2023. It is now read-only.

Cannot find jQuery when import bootstrap #192

Closed
inseptember opened this issue Apr 24, 2017 · 2 comments
Closed

Cannot find jQuery when import bootstrap #192

inseptember opened this issue Apr 24, 2017 · 2 comments
Labels

Comments

@inseptember
Copy link

Found an issue or bug? Tell me all about!

Describe the issue / bug.

#cannot find jQuery, after i set nodeIntegration: false, then report cannot find require function

How can I reproduce this problem?

#import jquery and bootstrap in main.js

If visual, provide a screenshot.

#

Tell me about your development environment.
  • Node version:6.10.2
  • NPM version:3.10.10
  • vue-cli version: (if necessary)2.8.1
  • Operating System:windows 10

If you are looking to suggest an enhancement or feature, then feel free to remove everything above.

@SimulatedGREG
Copy link
Owner

SimulatedGREG commented Apr 25, 2017

Okay so if you want to use regular jquery and bootstrap, here's what needs to be done...

Add ProvidePlugin in .electron-vue/webpack.renderer.config.js around line 90

new webpack.ProvidePlugin({
  $: 'jquery',
  jQuery: 'jquery'
})

and in main.js...

window.jQuery = window.$ = require('jquery/dist/jquery.min')
import 'bootstrap/dist/js/bootstrap.min'
import 'bootstrap/dist/css/bootstrap.min.css'

Now I highly discourage using jQuery and Vue in the same environment because you are now using two frameworks for the same app. This not only bloats your app size, but it can also very easily lead to anti-patterns between Vue and jQuery. As an alternative you can look into something like vue-strap which takes bootstrap's JS functionalities and converts them to Vue instead of jQuery. This alternative yields better control over your data in the long run.

@felipetesc
Copy link

Even though, this 'post' is closed, I wanted to ask what alternative to jquery I can use, and if any of you can share a possible suggestion. I'll hard code all components, but I really want a lib for dom manipulation. By the way, I'm not asking for something I can google, but what lib have you used in that way (dom manipulation) with electron-vue. TY!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants