context.renderScripts()报错, Cannot read property 'file' of undefined
来源:5-3 服务端渲染的entry配置
msidolphin
2018-07-05

server-render.js 代码
const ejs = require('ejs')
module.exports = async (ctx, renderer, template) => {
ctx.headers['Content-Type'] = 'text/html'
const context = {
url: ctx.path
}
try {
const appString = await renderer.renderToString(context)
const html = ejs.render(template, {
appString,
styles: context.renderStyles(),
scripts: context.renderScripts() // 报错
})
ctx.body = html
} catch (err) {
console.error('render error.')
throw err
}
}写回答
1回答
-
msidolphin
提问者
2018-07-05
这个解决了,客户端配置的output文件名配置错了
012021-04-12
相似问题