Recently, I've encountered some strange errors while working on a Vuejs project in VSCode. Whenever I try to write arrow functions or use brackets, I get unexpected character errors. For example, if I insert an empty computed
section between methods
and created
, like this:
methods: {
method1() {
// code here
},
method2(){
// code here
}
},
computed:{
},
created() {
if(this.condition){
require("prismjs/components/prism-python")
}
},
An error message pops up indicating:
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
In troubleshooting, I discovered that replacing the problematic computed
section with one from a functional file and then coding as usual resolves the issue. It seems like there may be something invisible being inserted by VSCode.
I've checked my extensions - only Vetur is installed, and even tried disabling and reinstalling it without success. Despite adjusting auto-insert settings, nothing seems to fix the problem except for potentially a full reinstallation of VSCode. Unfortunately, I couldn't find any similar cases through my search efforts online.
If anyone has experienced this unique issue before or can offer guidance, it would be greatly appreciated.