[Vuejs]-Error trying to attach external script to single file component in Vue

0👍

An invalid src path (i.e., ../javascripts/test.js) is likely the problem. Your server is probably configured with an index.html fallback, which is returned for files not found. You can confirm this in your browser’s developer tools (find test.js in Network Panel). Since the HTML file (which probably begins with <head>) is sourced into the <script>, you get a JavaScript syntax error for the < character of <head>.

You’ll need to update the src path to be relative to the root document and not to the directory of the component.

👤tony19

Leave a comment