我有一个HTML文本定义如下:
const helpContent ="<form name=\"punchout_form\" method=\"post\" action=\"https://openapi.alipaydev.com/gateway.do?charset=UTF-8&method=alipay.trade.page.pay&sign=nKG8mCXQlGKOHezlqu7nM9ZJWskZsYVzWyW4Rm0dS%2BT8A4iWs3A96gwaqcdCwINIYacXQbtErYAM7GNAaqWFTNdl33Xj%2BVbEPqew%2BXO2yoihRU8onV0Omt5eo01PRITGEbclLI5v6VmpBwzbrzMawu63dSXTRWJ2jRga5ZUr1cnvexYQj3NLWH5eQS7ZHXwLhbOFlVOyostdF%2FSd9YJTFNotz25K1eipLI4JdG3%2BtaLLBQsNDahET09KWkxKjALSrZGIT48KLOmKWDMXkXTJzHSxjvOFxYKtBmwRenkRxt1wTWX21LgLH3Bi8k4N1KFNuj4FxrzI%2FJGOa58%2BULO54Q%3D%3D&return_url=http%3A%2F%2Fdomain.com%2FCallBack%2Freturn_url.jsp¬ify_url=http%3A%2F%2Fdomain.com%2FCallBack%2Fnotify_url.jsp&version=1.0&app_id=2021000122621126&sign_type=RSA2×tamp=2023-03-07+02%3A00%3A53&alipay_sdk=alipay-sdk-java-4.35.65.ALL&format=json\">\n<input type=\"hidden\" name=\"biz_content\" value=\"{"extendParams":"dd","outTradeNo":"dd","passbackParams":"ddd","productCode":"productCode","subject":"ddd","sysServiceProviderId":"ddd","totalAmount":"1"}\">\n<input type=\"submit\" value=\"立即支付\" style=\"display:none\" >\n</form>\n<script>document.forms[0].submit();</script>";
然后我在react "react": "^17.0.1"
中呈现这个html文本,如下所示:
<div style={{paddingLeft: 15, textIndent: 2}} dangerouslySetInnerHTML={{__html:helpContent1}}></div>
让我困惑的是UI什么也不显示,我尝试定义一个简单的html文本,如下所示:
const helpContent1 ="<span>fwegewgwgwe</span>";
这工作正常,为什么长文本不能被呈现?我应该做什么使它工作如预期?我错过了什么?
1条答案
按热度按时间hjqgdpho1#
您的输入具有内联样式
style="display:none"
因此您的内容正在呈现,但被隐藏。删除该行,您将看到它。