[Vuejs]-How can I use the src imports in Vue3?

-1👍

You must just not wrap the content of the .js-file with script tags, since you are not writing this code in an HTML file. You do already specify to use javascript code by importing the file in <script setup />, so the compiler knows that the content of the .js-file contains JavaScript code.

It is similar to the CSS-file: Just delete the HTML-tags (<script> and </script>) from the beginning and the end of the .js-file, and you should be fine.

If this does not work, the error message says that script setup cannot be used with external file imports, so you might be forced to write the JavaScript code directly into your .vue-component-file.

👤STh

Leave a comment