基于 Vue 的预渲染解决方案
MIT License
Vue.js 2.0 + vue-router + prerender-spa-plugin 3.x Prerender SPA Example
prerender-spa-plugin
stable 3.x
puppeteer
2.x
PhantomJS
**** npm install
package-lock.json
node_modules
package-lock.json
node_modules
npm install --registry=https://registry.npm.taobao.org
web-bookmarks
npm cnpm
Demonstrates usage of Vuejs 2.0 with Vue Router and Webpack 3. Build will generate 6 static routes at the following paths:
/
/home
/information
/ticket
/scenery
/about
npm install
npm run build
****
npm install
package-lock.json
node_modules
package-lock.json
node_modules
npm install --registry=https://registry.npm.taobao.org
web-bookmarks
npm cnpm
Now check the new dist
directory for your prerendered static files!
To view the rendered files, you can
npm run prod
Now visit the following routes in your browser (note the trailing slash):
To edit the prerender-spa-plugin
configuration, look for new PrerenderSPAPlugin
in the plugins section of webpack.config.js
.
If you're using a router or have more than one page to prerender, edit the routes
array under that config object.
npm install
npm run dev
****
npm install
package-lock.json
node_modules
package-lock.json
node_modules
npm install --registry=https://registry.npm.taobao.org
web-bookmarks
npm cnpm
1.1 (npm run dev
)vue-router
history
2.1 (npm run build
)
2.2 vue-router
history
publicPath
./
QQ QQ 685486827