亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

react 服務端渲染怎么處理less文件

react 服務端渲染怎么處理less文件

當年話下 2018-11-13 13:13:36
背景:用react.js + node 實現react組件服務端渲染。由于當前 node 還不支持 import,我用nodemon --harmony server.js --exec babel-node命令執行,其中server.js是后端入口文件,這樣是可以支持 import 了,但是當我使用 antd 的 Button 組件時卻報不支持 @import, 因為 antd 的 button 組件導入了 default.less,怎樣才能解決這個問題呢?server.jsimport React, { Component } from 'react';import { renderToString } from 'react-dom/server'import { Button } from 'antd';var Koa = require('koa');var app = new Koa();const render = require('koa-ejs');const path = require('path');render(app, {  root: path.join(__dirname, 'server/view'),  layout: 'template',  viewExt: 'html',  cache: false,  debug: true});app.use(async function (ctx, next){  const html = renderToString(    <Button>hello</Button>  );  await ctx.render('demo', {'html': html});});app.keys = ['i love yuewen'];app.listen(3000);報錯如下:
查看完整描述

1 回答

  • 1 回答
  • 0 關注
  • 808 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號