HBuilder Vue 报错: Missing semicolon (103:20) 解决方法
在使用 HBuilder 开发 Vue 项目时,可能会遇到以下错误提示:
'D:\Work\HBuilder\diyijichu\pages\index\index.vue: Missing semicolon. (103:20)'
该错误提示表示在文件 'D:\Work\HBuilder\diyijichu\pages\index\index.vue' 的第 103 行缺少了分号(semicolon),可能是语法错误导致的。
错误代码示例:
methods: {
changeSlide(index) {
this.currentSlide = index
if (index % 3 === 0) {
this.swipers = this.swipers1
}
}
}
解决方案:
在第 103 行代码 this.currentSlide = index 末尾添加分号即可解决问题。
修改后的代码:
methods: {
changeSlide(index) {
this.currentSlide = index;
if (index % 3 === 0) {
this.swipers = this.swipers1
}
}
}
总结:
在 JavaScript 代码中,分号是语句的结束标志。如果缺少分号,会导致语法错误,从而导致程序无法正常运行。建议在编写代码时,养成良好的代码规范,在每个语句末尾添加分号,以避免此类错误的发生。
原文地址: https://www.cveoy.top/t/topic/lHW6 著作权归作者所有。请勿转载和采集!