SyntaxError: Unexpected token '<'
See original GitHub issue报错信息如下:
Date: 2020/1/2 下午5:10:37
SyntaxError: Unexpected token '<'
Unexpected token '<'
Page Url: http://**.cmfurl.cn/gjj/#/?Vlog=Y
User Agent: Mozilla/5.0 (iPhone; CPU iPhone OS 13_1_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148 MPBank/7.5.0 iPhone/13.1.2 Scale/3.0 AID/VXdF7ifNEFjE0rlkocs85Aljzwo= SID/lAvi3BAusTMd4dRxoqe5gSmXDnk= WebView/WKWebView APPTag/1.0(N;44;321)
页面可以代理过来,但获取vue节点#app的内容时报错。琢磨了好久无法解决,麻烦帮忙看一下是什么原因!
Issue Analytics
- State:
- Created 4 years ago
- Comments:6 (4 by maintainers)
Top Results From Across the Web
SyntaxError: Unexpected token - JavaScript - MDN Web Docs
The JavaScript exceptions "unexpected token" occur when a specific language construct was expected, but something else was provided.
Read more >Have a JavaScript Unexpected Token Error? Check Your Syntax
The JavaScript's parser expects tokens and symbols in a particular order, with relevant values or variables in between. Often, an Unexpected ...
Read more >syntax error: unexpected token - javascript - Stack Overflow
The error SyntaxError: Unexpected token < likely means the API endpoint didn't return JSON in its document body, such as due to a...
Read more >JavaScript SyntaxError - Unexpected token - GeeksforGeeks
This JavaScript exceptions unexpected token occur if a specific language construct was expected, but anything else is typed mistakenly.
Read more >SyntaxError: Unexpected token in JavaScript - Stack Diary
The "SyntaxError: Unexpected token" error in JavaScript is a common syntax error that occurs when the JavaScript interpreter encounters a ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
问题解决了,是我本地的Whistle rules写错了,应该是rule匹配却因为少了一个
/
,Whistle默认转成了host匹配,所以文件找不到。 本地打包好的js文件放在127.0.0.1:8080/
目录下,即通过127.0.0.1:8080/*.js
能加载成功,如果通过路径为127.0.0.1:8080/gjj/*.js
就找不到,找不到时默认返回index.html文件,html文件以js格式解析所以报SyntaxError: Unexpected token ‘<’,因为html文件是以<!DOCTYPE html>
开头;配置问题解析: rules配置:
**.cmfurl.cn/gjj/ 127.0.0.1:8080
(错误) 改成: rules配置:**.cmfurl.cn/gjj/ 127.0.0.1:8080/
(正确) 即可。错误的rules配置,相当于请求
**.cmfurl.cn/gjj/
中的js文件时代理到127.0.0.1:8080/gjj
中查找相应的js文件。这是host匹配,127.0.0.1:8080
匹配**.cmfurl.cn
正确的rules配置,相当于请求
**.cmfurl.cn/gjj/
中的js文件时代理到127.0.0.1:8080/
中查找相应的js文件。这是rule匹配,127.0.0.1:8080/
匹配**.cmfurl.cn/gjj/
host 和 URL 替换的区别参考下这篇文章:https://juejin.im/post/5e14445be51d45415a66754a