我是本机反应的新手。实际上,我想从HTML字符串创建PDF,但是我想从状态变量中添加数据。
类似的东西,但是不知道正确的方法。
const htmlString = `
<h1>Name: {this.state.name}</h1>
<h2>Mobile number: {this.sate.mobileNumber}</h2>
<img src="https://www.gstatic.com/webp/gallery/1.jpg" />
`;
预先感谢您的帮助。
答案 0 :(得分:2)
您应该使用字符串模板文字表示法:${variable}
const htmlString = `
<h1>Name: {this.state.name}</h1>
<h2>Mobile number: ${this.sate.mobileNumber}</h2>
<img src="https://www.gstatic.com/webp/gallery/1.jpg" />
`;