Comments (13)
@reg21st 嗯,之前的回答不够完整,在 dev 模式下可以使用 connect-history-api-fallback
,来解决刷新 404 的问题,
dev-server.js 中设置
// handle fallback for HTML5 history API
var history = require('connect-history-api-fallback')
app.use(history({
index: '/index.html',
rewrites: [
{ from: /^\/indx\/.*$/, to: '/index.html'}, // 默认入口
{ from: /^\/index2\/.*$/, to: '/index2.html'}, // 其他入口
]
})
)`
from vue-cli-multipage.
这个问题是需要做 http server 配置 看这个文档http://router.vuejs.org/zh-cn/essentials/history-mode.html
from vue-cli-multipage.
@Deguang 你这种配置只是单一路由,不能解答题主的疑问。文章指出了把URL配比不到资源时,指向全部依赖的index.html。题主是多路由,不同路由依赖不同的页面。
from vue-cli-multipage.
@Deguang 那么生产环境呢?依旧是多路由啊
from vue-cli-multipage.
@reg21st 生产环境 参考 上述 router 文档,配置多 try_files,下面以 nginx 为例:
location ~ ^/(index) {
try_files $uri $uri/ /index.html;
}
location ~ ^/(anotherIndex) {
try_files $uri $uri/ /anotherIndex.html;
}
这边有项目 使用 多入口 的spa 模式在线上部署,有问题可以交流 : )
from vue-cli-multipage.
@Deguang 谢谢~多多交流。我们前些日子也部署了这种项目,单个的SPA,也是用nginx。这种方式理解,只是感觉这种配置方式相对来说,需要在服务器配置多条,试图寻求更便捷的方式。
from vue-cli-multipage.
@reg21st 嗯,确实需要在线上服务器增加非常多条目的配置项,比较冗余,sa 在调研新的 proxy 配置方案,有眉目了可以互通下
from vue-cli-multipage.
@Deguang
对于公共资源 你们是如何处理的?都打包成一个单独文件吗?
方便的情况下,可以分享下你们的构建,我倒腾了很久,始终没有成熟方案。
from vue-cli-multipage.
@reg21st 优化还没开始全面做,几个思路吧,公共资源 dll 打包抽离,过大的静态资源剥离,组件 异步加载,大的资源包分片。 整体就是 权衡请求数和资源包的尺寸上找平衡
from vue-cli-multipage.
@Deguang 通过nginx能指定跳转到当前页面吗?要是刷新跳转不到当前页面确实是很尴尬的一件事,老板肯定不干呢
from vue-cli-multipage.
@Deguang hash模式可以的,但是url太丑了,没法目视
from vue-cli-multipage.
@zhenwoo 对,Nginx,做try_files
from vue-cli-multipage.
怎么配置多页面,多路由,就是多页面就的url是以.html结尾的,现在有需求是/xx.html/a这种怎么配置
from vue-cli-multipage.
Related Issues (20)
- 在vue组件里使用saas会报错 HOT 1
- vue-cli 懒加载配置 HOT 3
- 请问一下如果在开发环境,CSS也作为文件引入,应该怎么改配置? HOT 1
- Cannot GET / HOT 2
- 有个严重的问题,build之后的vendor.js把所有页面引入的库都放进去了 HOT 11
- 设置proxyTable失效 HOT 1
- 在module文件夹下添加新的文件夹编译会报错,并且不能访问 HOT 6
- 修改过后的版本,外部引入的css还是不能自动添加前缀 HOT 1
- 兄弟你这个配制方法,每个moudle相当于一个template, 和单页应用也差不多。不过看到你的玩法,启发很大。 HOT 3
- 怎么不启用vue-tools
- 单元测试出错
- 貌似不可以在page Folder 里面再创建一个.js文件
- 多页跳转页面,后退不刷新页面 HOT 1
- 大佬,你好,我是小白,我想问问 添加新的页面 怎么做 ?没法实现 HOT 1
- 登录页和主页是不是可以用多页面处理(后台管理系统) HOT 1
- 我想问下根目录没有了index.html运行项目的时候怎么去设置默认的页面
- 设置proxyTable失效
- npm run build出来的图片路径有问题
- 模块多路由怎么不生效呢?谢谢答主
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from vue-cli-multipage.