[英]Pass variable from express server to react application
所以我正在使用普遍的反应 ,我想从服务器传递一些变量值到反应应用程序,而不必在加载后执行ajax请求。 反应应用程序加载如下:
const someVariable = 'some variable';
// The React application middleware.
app.get('*', reactApplication);
如何将其传递给down以便它可以在react应用程序中使用?
您可以在express/node-server:
添加标头属性express/node-server:
res.writeHead(statusCode , {header properties})
(fast, not cached by default)
-要么-
解析你的索引文件并将你的属性注入头部(不是很快,可以缓存得更快)并检查该属性是否与
document.getElementById('propertyId')
-要么-
document.getElementByTagName('propertyTag')
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.