我想给content属性的字符串之间留行距。我该怎么给?像在万维网字符串之后一样,我想从新行开始新的字符串。在这里看我的代码 注意:我在React Native Application中使用它
class MyComponent extends Component {
...
someCallback() {
const validationErrors = someFunctionThatReturnsErrors();
// We do the logic here, because we know that validationErrors
// could have changed value
const { errorsText, errorsFields } = validationErrors.reduce(
(acc, error) => {
acc.errorsText.push(error.text);
acc.errorsFields[error.field.toLowerCase()] = true;
return acc;
}, {
errorsText: [],
errorsFields: {},
},
);
// Put everything in the state
this.setState({
validationErrors, // you may not even need to set this if it's not used elsewhere`
errorsText,
errorsFields
});
}
...
render() {
const {
errorsText,
errorsFields
} = this.state;
return (
<MyViewComponent
errorsText={errorsText}
errorsFields={errorsFields}
/>
);
}
}
答案 0 :(得分:1)
尝试使用反引号``而不是“''。那将解决您的问题。像
content: `HTML stands for HyperText Markup Language
HTML is the basic building block of World Wide Web.
`
查看有效示例snack。
希望有帮助。毫无疑问。