【问题标题】:React static files not rendering inside html反应静态文件不在html内呈现
【发布时间】:2021-07-08 09:29:52
【问题描述】:

我在流式文件中渲染 React HTML 时遇到了困难。

我总共有 3 个应用程序。

Strapi - https://my-api.com
React App - https://my-react-app.com
shopify store - https://shopify-store.com

GET https://shopify-store.com  ->>  GET https://my-api.com/api/get-form

上面的 URL 请求由 Shopify 商店应用发送到我的strapi 服务器,我必须返回一个 HTML。

/api/*/controller/fileName.js

const { data } = await axios.get('https://my-react-app.com/form-page');
// the above data contains react's html
ctx.send(data); // returning react's HTML to shopify store

我已经完成了上述方法,它返回 HTML,但它没有在 UI 中呈现 Html。 如果您从屏幕截图中注意到,<div id="main"></div> 是空的。

请帮我找到一个渲染 HTML 的解决方案……

谢谢。

【问题讨论】:

    标签: reactjs strapi koa shopify-app shopify-template


    【解决方案1】:

    假设您的应用通过脚本标签 api 更改液体文件。

    将你的 html 作为字符串返回

    "<html><body></body></html>"
    

    请提供您收到 html 的文件的更多详细信息并将其设置为 shopify 商店。

    【讨论】:

      猜你喜欢
      • 2017-12-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-03-13
      • 1970-01-01
      • 2012-01-21
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多