problem description
the title may not be well described. Let"s explain in detail what text conversion means.
for example, I received a field called content, from the background, but if I want to put it in the selector, I need to use the copy: thi first content.
corresponding to content. It"s very simple, but I only know stupid methods. I hope I can absorb your experience. Every progress comes from a small change.
the environmental background of the problems and what methods you have tried
current method I use:
create a new js, for storing fields and field copy, import this copy in the component, pass in the corresponding value, and get the result returned by the js
related codes
/ / Please paste the code text below (do not replace the code with pictures)
//dataJson.js
module.exports = {
dataContent:{
"content": "the first content",
"content1": "the second content",
"content2": "the third content",
}
}
//
import { dataContent } from "./dataJson.js"
this.state={
dataName:["content", "content1", "content2"]
}
dataName.map( item => (
<div key={item}>
<span>{item}</span>
<span>{dataContent[item]}</span>
</div>
))
what result do you expect? What is the error message actually seen?
I hope there is a more efficient way to implement this function. Or have more ideas. The problem is very simple. I just want to try to learn more ideas. I beg your pardon