版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/daoer_sofu/article/details/102481880
npm install express -g
npm install express-generator -g
后端语言+模板,后端渲染方式
express projectname 使用jade模板
express -e projectname 使用ejs模板
jade:html模板引擎(调试困难,性能低) 建议改用ejs模板
npm start 访问:http://localhost:3000
创建react应用
cnpm install create-react-app
create-react-app projectname
express不使用动态语言+模板,直接返回react静态资源即可 使用
//指向react生成的目录,静态服务器的默认入口是index.html,如果找不到也可以手动修改url路径
app.use(express.static("../test/build"));
//app.use('/', indexRouter); 根目录的route会导致页面刷新
node www 启动express
react app 遵循pwa设计,包含web app manifest、service worker