Vue uses iconfont to report an error Uncaught SyntaxError: Unexpected token <

because of environmental problems, cdn is used before downloading to the local form to use iconfont,. Cdn can display the icon normally, but it will report an error if it is changed to a local one:

clipboard.png

:

clipboard.png

clipboard.png

could you tell me how to solve this problem?

Apr.05,2021

iconfont.css should be dependent on iconfont.js, right? Why not all import with import? I think it's a bit of a problem to import one with script.


I encountered the same problem, prompting "Unexpected token <" error.

my previous approach is to introduce
< script src= ". / assets/icons/iconfont.js" > < / script >

in the index.html file in symbol mode.

then prompt for an error. My guess is that some syntax in the iconfont.js file needs to be processed before it can be read, and the index.html is not processed as needed. Of course, this is a guess, I do not know the real reason.

I didn't know what to do with it, so I bypassed it, that is, I introduced it directly into the xxx.vue file:
import "@ / assets/icons/iconfont.js"

of course, style, is also set so you can use the svg tag to display icons.

Menu