在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称:koajs/react-view开源软件地址:https://github.com/koajs/react-view开源编程语言:JavaScript 100.0%开源软件介绍:koa-react-viewA Koa view engine which renders React components on server. Installation$ npm install koa-react-view Usagevar react = require('koa-react-view');
var path = require('path');
var koa = require('koa');
var app = koa();
var viewpath = path.join(__dirname, 'views');
var assetspath = path.join(__dirname, 'public');
react(app, {
views: viewpath
});
app.use(function* () {
this.render(home, {foo: 'bar'});
}); This module no longer includes the Babel runtime, as that prevented developers from using the runtime on the server outside of the scope of this module. Additionally, Babel recommends that the polyfill is only included by the parent app to avoid these conflicts. If you'd like to use JSX, ES6, or other features that require transpiling, you can include Babel in your project directly. See example. Options
renderToString vs renderToStaticMarkupReact provides two ways to render components server-side:
By default, the
|
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论