【问题标题】:what does it mean "Legacy octal literals are not allowed in strict mode" in ReactJS?ReactJS中的“严格模式下不允许使用传统八进制文字”是什么意思?
【发布时间】:2021-07-31 16:45:46
【问题描述】:

我正在尝试遍历这些数组,但收到此错误“在严格模式下不允许使用传统八进制文字”

const myList =[
    {
        id: 01,
        title: 'FrontEnd Engineer',
        name : 'Sheshathri',
        describtion: "simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book"
    },
    {
        id: 02,
        title: 'QA Engineer',
        name : 'Jobin',
        describtion: "It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum."
    }
  ]
  
  export default myList;

在 App.js 中

import myList from './ContentList';

const listItem = myList.map(list => <Content key= {list.id} title = {list.title} name = {list.name} describtion = {list.describtion} />);

【问题讨论】:

  • 严格模式默认会抛出遗留方法/代码错误,你应该避免遗留代码

标签: javascript arrays reactjs object react-props


【解决方案1】:

我正在尝试遍历这些数组,但出现此错误 “严格模式下不允许使用传统八进制文字”

指的是你的id:

id: 01,
title: 'FrontEnd Engineer',

替换为

id: 1,
title: 'FrontEnd Engineer',

八进制字面量是以零开头的数字,例如:

变量数 = 071; // 57

识别八进制文字的前导零是 JavaScript 中的混乱和错误。 ECMAScript 5 不赞成使用 JavaScript 中的八进制数字文字和八进制文字导致语法 严格模式下的错误。

Octal系统

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-08-18
    • 2016-08-21
    • 2021-03-31
    • 1970-01-01
    • 2016-03-25
    • 2021-08-29
    • 2014-06-29
    • 2018-11-11
    相关资源
    最近更新 更多