您正在寻找的是服务器端渲染.我建议你看看Nuxt.js.
Properly configuring all the discussed aspects of a production-ready
server-rendered app can be a daunting task. Luckily, there is an
excellent community project that aims to make all of this easier:
Nuxt.js. Nuxt.js is a higher-level framework built on top of the Vue
ecosystem which provides an extremely streamlined development
experience for writing universal Vue applications. Better yet, you can
even use it as a static site generator (with pages authored as
single-file Vue components)! We highly recommend giving it a try.
得到它是非常简单的started.如果你使用vue-cli:
$vue init nuxt/starter
它配备了您通常需要的所有功能(Vuex,Router,..).请记住,它强制执行一些您必须遵循的文件夹结构.
Here是启动器中包含的命令列表.
"scripts": {
"dev": "nuxt",
"build": "nuxt build",
"start": "nuxt start",
"generate": "nuxt generate"
}
你可能会主要对generate进行迭代
Build the application and generate every route as a HTML file (used
for static hosting).
同样值得注意的是该项目似乎是(在撰写本文时)under active development,我们可以期待更多出色的功能!