我如何在渲染部分中使用脚本标记进行反应

时间:2017-07-19 10:01:06

标签: javascript html reactjs react-redux

我想在返回阶段使用此脚本,该脚本来自https://www.omise.co/card-js-api

<modelNormalBodyPartResult: modelNormalBodyPartResult object> needs to have a value for field "modelnormalbodypartresult" before this many-to-many relationship can be used.

但它似乎根本不起作用

2 个答案:

答案 0 :(得分:0)

必须在</script><script type="text/javascript" src="https://cdn.omise.co/card.js" data-key="YOUR_PUBLIC_KEY" data-image="PATH_TO_LOGO_IMAGE" data-frame-label="Merchant site name" data-button-label="Pay now" data-submit-label="Submit" data-location="yes" data-amount="10025" data-currency="thb" > </script>标记之间插入Javascript。

&#13;
&#13;
{{1}}
&#13;
&#13;
&#13;

就我而言,自闭标签不适用。

这应该为您提供一个很好的参考 - Why don't self-closing script tags work?

答案 1 :(得分:0)

将模板字符串与React

一起使用
var script = `<script type="text/javascript" src="https://cdn.omise.co/card.js"
      data-key="YOUR_PUBLIC_KEY"
      data-image="PATH_TO_LOGO_IMAGE"
      data-frame-label="Merchant site name"
      data-button-label="Pay now"
      data-submit-label="Submit"
      data-location="yes"
      data-amount="10025"
      data-currency="thb"></script>`;

document.body.appendChild(script);