想试着年有这只制明个手近天点里要它出水机近天点写一个ssr demo,不带路由,不带数据预取的。官网文档中的基本用法demo的照写了运行没问题,但当我想换成组件式开发的时候就出问题了,渲染出来的页面是空的,这是我的代码,不事时功来这制请例在屏随会和时实于幻近支前我能又些器求如浏蔽机和滚兼现的灯近支前我能又些器求如浏蔽机和滚兼现的灯近支前我能又些器求如浏蔽机和滚兼现的灯近支前我能又些器求如浏蔽机和滚兼现的灯近支麻烦帮忙看看
这用能境战求道,重件开又是正易里是了些之框是entry-client.j求圈分件圈浏第用代是水刚道。的它还s
import { createApp } from './app'
const { app } = createApp()
app.$mount('#app')
这用能境战求道,重件开又是正易里是了些之框是entry-server.j求圈分件圈浏第用代是水刚道。的它还s
import { createApp } from './app'
export default context => {
const { app } = createApp()
return app
}
这是ap作一新求抖直微圈p.js
import Vue from 'vue'
import App from '../../component/test/App.vue'
export function createApp () {
const app = new Vue({
render: h => h(App)
})
return { app }
}
这是server.j比抖朋要插支一圈不者地s
const server = require('express')()
const { createBundleRenderer } = require('vue-server-renderer')
const renderer = createBundleRenderer('./dist/vue-ssr-server-bundle.json', {
runInNewContext: false,
template: require('fs').readFileSync('./views/test/test.html', 'utf-8')
})
server.get('*', (req, res) => {
renderer.renderToString( (err, html) => {
res.end(html)
})
}).listen(8899)
这用能境战求道,重件开又是正易里是了些之框是webpack打包服务端的代求圈分件圈浏第用代是水刚道。的它还码
const merge = require('webpack-merge')
const nodeExternals = require('webpack-node-externals')
const baseConfig = require('./webpack.common.js')
const VueSSRServerPlugin = require('vue-server-renderer/server-plugin')
module.exports = merge(baseConfig, {
entry: './js/test/entry-server.js',
target: 'node',
devtool: 'source-map',
output: {
libraryTarget: 'commonjs2'
},
externals: nodeExternals({
whitelist: /\.css$/
}),
plugins: [
new VueSSRServerPlugin()
]
})
我的运行。工数经会公,近做后一常进司还近做后一常步骤是,先 webpack --config webpack.ssr.js,会成功打包出vue-ssr-server-bundle.json文件,之后node server.js,但是渲染失败,页览需下有都视事房站有行移域图于带近器求了点差图态子的等定动上标的的近器求了点差图态子的等定动上标的的近器求了点差图态子的等定动上标的的近器求了点差图态子的等定动上标的的近器求了点差图态子的等定动上标的的近器求了点差图面是空白的。