猿问

用来自 JSON 的字符串中的变量值替换 ${dummy}

我有一个 Json 文件


[

"Cooling":

  {

    "id": 1,

    "title": "Cooling",

    "description": "Lorem Ipsum is 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"

  }

]

我想在渲染之前根据某些条件将 ${dummy} 替换为其他内容。这在反应中可能吗?


我在我的 react App.js 组件中导入这个文件并将其显示为:


return (

    <div>

      <div className="row">

        {Json.map(item => (

          <div className="col-md-1">

            <hr />

            <p key={item.id}>

              {item.title}

            </p>

            <p>{item.description}</p>

          </div>

        ))}

      </div>

    </div>

  );

这里可以在渲染之前替换 item.description 中的 ${dummy} 吗?


哆啦的时光机
浏览 319回答 1
1回答
随时随地看视频慕课网APP

相关分类

JavaScript
我要回答