将服务器上的flask python变量作为props传递给reactjs

IT技术 python reactjs flask
2021-05-15 19:48:54
I'm trying to pass flask variables from the server to react but I can't get it working. At the moment I have a render function in a reactjs file that looks like:
ReactDOM.render(
  <Attribute prop1='{{ prop1 }}' prop2='{{ prop2 }}' />,
  document.getElementById('main')
);

在flask服务器上的python中,我有:

return render_template('index.html', prop1=var1, prop2=var2)
1个回答

它应该是

  <Attribute prop1={ prop1 } prop2={ prop2 } />