We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
npm i prerender-spa-plugin -D
routes
staticDir
// 引入 const PrerenderSPAPlugin = require('prerender-spa-plugin'); const Renderer = PrerenderSPAPlugin.PuppeteerRenderer; // plugins module.exports = { // ... chainWebpack: config => { config .plugin('prerender-spa-plugin') .use(PrerenderSPAPlugin, [{ staticDir: path.join(__dirname, 'dist'), routes: ['/', '/home', '/product', '/contact'], minify: { minifyCSS: true, removeComments: true // 移除注释 }, renderer: new Renderer({ inject: { foo: 'bar' }, headless: true, renderAfterDocumentEvent: 'render-event', // renderAfterTime: 5000 // 不完全是静态时用于获取数据后再保存渲染结果 }) }]) .end() } }
new Vue({ router, render: h => h(App), mounted() { document.dispatchEvent(new Event('render-event')) } }).$mount('#app')
yarn build 打包生成目录
keyWords
description
npm i vue-meta-info
main.js
import MetaInfo from 'vue-meta-info' Vue.use(MetaInfo)
在相应的vue页面的配置
export default { metaInfo: { meta: [ { name: "keyWords", content: "ETC, ETC卡, ETC系统服", }, { name: "description", content: "中数信信息服务为企业提供车辆管理平台,并联合银行APP,支持企业对挂靠车辆实现ETC申卡、信用额度分配、ETC过路费及油费的支、还款及额度恢复、一键锁车、一键解锁等管理功能", }, ], }, // ... }
生成自定义的 meat 标签
本地服务预览:
未使用预渲染页面效果:
使用预渲染页面效果:
未配置预渲染路由页面效果:
The text was updated successfully, but these errors were encountered:
No branches or pull requests
预渲染
npm i prerender-spa-plugin -D
routes
对应自己的路由文件,比如a有参数,就需要写成 /a/param11、vue.config.js
routes
需要生成预渲染的路由staticDir
生成多页面的目录 只能是一级目录2、main.js文件
3、SEO优化
keyWords
description
npm i vue-meta-info
4、安装 http server 插件
The text was updated successfully, but these errors were encountered: