Unresolved variable or type Vue

Hi Everyone,

I started learning Vue.js and I am using WebStorm as my editor.

 

I added following line to index.html file, right on top of closing body tag:

<script src="https://unpkg.com/vue@next" defer></script>
<script src="app.js" defer></script>

 

I also clicked on the light bubble thing and downloaded the library.

Now in the app.js, I have following code:

Vue.createApp({
data() {
return {
myData: 'Text here'
};
}
}).mount("#user-goal");

Now there are 3 problems with this setup.

1-) in line

Vue.createApp({

Vue is underlined yellow and when I hover the mouse over it, I get "Unresolved variable or type Vue" error.

 

2-) In the same line above, the autocomplete does not work when i start typing "Vue.crea....". How can I make sure that the auto complete actually parses and shows suggestions for functions that belong to Vue.

3-) In the following line:

}).mount("#user-goal");

mount is underlined and I see "Unresolved function or method mount()"

 FYI, I tried right clicking on the file and selecting "Uses JavaScript Library" then "Vue". It is already selected and marked gray. So I cant make any changes there.

 

 

 

 

4 comments
Comment actions Permalink

The reason is that the downloaded file doesn't have any extension, and thus is not treated as JavaScript

To work out the issue, you need associating it with JavaScript file type: expand the External Libraries node in project tree, locate the downloaded library there, choose Associate with File Type.. from its right-click menu, choose JavaScript from the list

 

2
Comment actions Permalink

That worked. Thanks a lot!!

0
Comment actions Permalink

I've done this but my methods in the html are still unresolved.

0
Comment actions Permalink

Please follow https://youtrack.jetbrains.com/issue/WEB-52495 for updates

As a workaround, try downloading vue.global.js from https://unpkg.com/browse/vue@3.2.6/dist locally and then include it in your page with <script src="path/to/vue.global.js">

1

Please sign in to leave a comment.