inrate
inrate

Reputation: 365

How to connect other JavaScript file to Vue file without any error?

I want to connect other .js file to my .vue file.
So, i use theese line of code in my .vue file:

import  jQuery from 'jquery'
import './assets/js/script'

But, the console in Chrome (and other browsers) say:

Uncaught ReferenceError: jQuery is not defined

I don't get why is it happening because i import jQuery var. and i use jQuery(). structure in my .js file

UPD: Sure, i have used npm install jquery;
I have also tried to use var jQuery = require("jquery")

Upvotes: 0

Views: 32

Answers (1)

TJ Weems
TJ Weems

Reputation: 1114

Try

import $ from 'jquery'

As suggested in the comments.

There are multiple ways to implement jquery into your project. For other people who come across this question I will reference a few links you can try if the above suggestion does not work.

article 1

article 2

Upvotes: 1

Related Questions