简体   繁体   English

ReactJs 如何修复“render()”中缺少的分号错误

[英]ReactJs how can I fix missing semicolon error at "render()"

I don't know where I missed the semi-colon.我不知道我在哪里错过了分号。 bellow is the error code.下面是错误代码。

Syntax error: Missing semicolon.语法错误:缺少分号。 (106:11) (106:11)

  104 |   }
  105 |
  106 |   render() {
      |           ^
  107 |     return (
  108 |       <div className="App">
  109 |         <ParticlesBg type="circle" bg={true} />

Could you post the code in line 106.你能把代码贴在第 106 行吗?

One of the following could be the reason for your error,以下之一可能是您出错的原因,

  1. Unescaped strings : This error can occur easily when not escaping strings properly and the JavaScript engine is expecting the end of your string already.未转义的字符串:如果没有正确转义字符串并且 JavaScript 引擎已经在等待字符串的结尾,则很容易发生此错误。 Eg:例如:

    var foo = 'Tom's bar'; var foo = '汤姆的酒吧'; // SyntaxError: missing ; // 语法错误:缺少; before statement声明前

Could be corrected as,可以更正为,

var foo = "Tom's bar";
  1. Declaring properties with var : You cannot declare properties of an object or array with a var declaration.使用 var 声明属性:您不能使用 var 声明来声明对象或数组的属性。

    var obj = {}; var obj = {}; var obj.foo = 'hi'; var obj.foo = 'hi'; // SyntaxError missing ; // 缺少语法错误; before statement声明前

    var array = []; var 数组 = []; var array[0] = 'there'; var array[0] = '那里'; // SyntaxError missing ; // 缺少语法错误; before statement声明前

Could be corrected as,可以更正为,

var obj = {};
obj.foo = 'hi';

var array = [];
array[0] = 'there';

You can check out more about it from here : here您可以从这里查看更多信息: 这里

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM