VSCode 和 Vue:意外字符“”
VSCode and Vue: Unexpected character ''
我正在使用 VSCode 进行一个规模较大的 Vuejs 项目,但是,当我编写任何箭头函数或任何涉及括号的内容时,我总是遇到奇怪的意外字符错误。例如,如果我要在 methods
和 created
中间添加一个空的 computed
,如下所示:
methods: {
method1() {
// sample code here
},
method2(){
// sample code here
}
},
computed:{
},
created() {
if(this.condition){
require("prismjs/components/prism-python")
}
},
我会得到这个错误:
Syntax Error: SyntaxError: /home/me/Documents/project/src/views/folder/file.vue: Unexpected character '' (86:13)
84 | }
85 | },
> 86 | computed:{
| ^
87 |
88 | },
89 |
@ ./src/views/folder/file.vue?vue&type=script&lang=js& 1:0-292 1:308-311 1:313-602 1:313-602
@ ./src/views/folder/file.vue
@ ./src/router/index.js
@ ./src/main.js
@ multi (webpack)-dev-server/client?http://192.168.1.175:8080&sockPath=/sockjs-node (webpack)/hot/dev-server.js ./src/main.js
但是如果我从另一个工作文件中复制粘贴一个 computed
来代替当前的 computed
,删除里面的所有内容并正常编码,一切正常,所以它是可以安全地假设 VSCode 正在插入 某些东西(显然我看不到)。
除了 Vetur,我没有任何扩展,我什至尝试 disabling/reinstalling 看看是否是问题所在。
我已经尝试了所有方法,从摆弄自动插入设置到直接重新安装 VSCode。我找遍了 google,但出于某种原因,我找不到其他人遇到这个特定问题。
如有任何帮助,我们将不胜感激。
根据我的意见:确保选中 [View][Render Control Characters] 顶部菜单。可能输入了 non-printing 个 UTF 字符。您的语言环境是什么?或者,将文件编码更改为 ASCII,看看会发生什么。
我正在使用 VSCode 进行一个规模较大的 Vuejs 项目,但是,当我编写任何箭头函数或任何涉及括号的内容时,我总是遇到奇怪的意外字符错误。例如,如果我要在 methods
和 created
中间添加一个空的 computed
,如下所示:
methods: {
method1() {
// sample code here
},
method2(){
// sample code here
}
},
computed:{
},
created() {
if(this.condition){
require("prismjs/components/prism-python")
}
},
我会得到这个错误:
Syntax Error: SyntaxError: /home/me/Documents/project/src/views/folder/file.vue: Unexpected character '' (86:13)
84 | }
85 | },
> 86 | computed:{
| ^
87 |
88 | },
89 |
@ ./src/views/folder/file.vue?vue&type=script&lang=js& 1:0-292 1:308-311 1:313-602 1:313-602
@ ./src/views/folder/file.vue
@ ./src/router/index.js
@ ./src/main.js
@ multi (webpack)-dev-server/client?http://192.168.1.175:8080&sockPath=/sockjs-node (webpack)/hot/dev-server.js ./src/main.js
但是如果我从另一个工作文件中复制粘贴一个 computed
来代替当前的 computed
,删除里面的所有内容并正常编码,一切正常,所以它是可以安全地假设 VSCode 正在插入 某些东西(显然我看不到)。
除了 Vetur,我没有任何扩展,我什至尝试 disabling/reinstalling 看看是否是问题所在。 我已经尝试了所有方法,从摆弄自动插入设置到直接重新安装 VSCode。我找遍了 google,但出于某种原因,我找不到其他人遇到这个特定问题。
如有任何帮助,我们将不胜感激。
根据我的意见:确保选中 [View][Render Control Characters] 顶部菜单。可能输入了 non-printing 个 UTF 字符。您的语言环境是什么?或者,将文件编码更改为 ASCII,看看会发生什么。