[Turn] Vue project error: Uncaught SyntaxError: Unexpected token <

  This article describes the Vue project error: Uncaught SyntaxError: Unexpected token <, dependent upon the introduction of third-party JS files, encountered a problem, Xiao Bian feel very good, for everyone to share now, but also for everyone to be reference. Come and see, to follow the small series together

 

Encounter problems:

  VUE to do a project today, when the introduction of third-party dependent JS files, encountered a problem:

  

  Console prompt:Uncaught SyntaxError: Unexpected token <

 

  Follow the prompts to enter the file, look at the following chart:

  

 

  Carefully looked at the index.html file, find the original file is on my JS / src / utils folder, but the introduction of / src and / static files are different.

 

solution:

  The solution is to rely on third-party JS files into the / static under / utils directory, introducing path also changed: <script src = "./ static / utils / sockjs.js"> </ script>, so that no error up!

 

to sum up:

  1, assets folder difference between static folder

    A difference: assets file is that it is necessary to package the final run in src, and static files do not need to pack directly on the final document

    Difference between the two: ../ performed with this form of assets in the relative path of the file vue template / style reference, and must be introduced anywhere in a static file in script .vue in a manner @import As long as this embodiment are used ../ relative path is introduced,

  2、

    (1) assets used to place style, still images, as long as the src components used in the following resources are placed in assets.

  (2) static npm package to put no third-party plug-ins, font files.

  When (3) assets referenced in static files and .vue components similar components, the relative path is ../assets/wapFront

  3, vue how to introduce other static file:

    (1) resources under src directory can only import or require.

    (2) wants to introduce static, then the establishment of a directory and src same level such as static, then the static resource into the folder, the introduction path html as follows: ./ static / ... (Note: must be tried on the static folder, otherwise an error)

  

That's all for this article, we want to be helpful to learn, I hope you will support script home.

 

Original Address: http://www.manongjc.com/article/17978.html

Guess you like

Origin www.cnblogs.com/tynam/p/11210535.html