GithubHelp home page GithubHelp logo

Comments (13)

Deguang avatar Deguang commented on June 24, 2024 2

@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.

Deguang avatar Deguang commented on June 24, 2024

这个问题是需要做 http server 配置 看这个文档http://router.vuejs.org/zh-cn/essentials/history-mode.html

from vue-cli-multipage.

suweiteng avatar suweiteng commented on June 24, 2024

@Deguang 你这种配置只是单一路由,不能解答题主的疑问。文章指出了把URL配比不到资源时,指向全部依赖的index.html。题主是多路由,不同路由依赖不同的页面。

from vue-cli-multipage.

suweiteng avatar suweiteng commented on June 24, 2024

@Deguang 那么生产环境呢?依旧是多路由啊

from vue-cli-multipage.

Deguang avatar Deguang commented on June 24, 2024

@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.

suweiteng avatar suweiteng commented on June 24, 2024

@Deguang 谢谢~多多交流。我们前些日子也部署了这种项目,单个的SPA,也是用nginx。这种方式理解,只是感觉这种配置方式相对来说,需要在服务器配置多条,试图寻求更便捷的方式。

from vue-cli-multipage.

Deguang avatar Deguang commented on June 24, 2024

@reg21st 嗯,确实需要在线上服务器增加非常多条目的配置项,比较冗余,sa 在调研新的 proxy 配置方案,有眉目了可以互通下

from vue-cli-multipage.

suweiteng avatar suweiteng commented on June 24, 2024

@Deguang
对于公共资源 你们是如何处理的?都打包成一个单独文件吗?
方便的情况下,可以分享下你们的构建,我倒腾了很久,始终没有成熟方案。

from vue-cli-multipage.

Deguang avatar Deguang commented on June 24, 2024

@reg21st 优化还没开始全面做,几个思路吧,公共资源 dll 打包抽离,过大的静态资源剥离,组件 异步加载,大的资源包分片。 整体就是 权衡请求数和资源包的尺寸上找平衡

from vue-cli-multipage.

zhenwoo avatar zhenwoo commented on June 24, 2024

@Deguang 通过nginx能指定跳转到当前页面吗?要是刷新跳转不到当前页面确实是很尴尬的一件事,老板肯定不干呢

from vue-cli-multipage.

zhenwoo avatar zhenwoo commented on June 24, 2024

@Deguang hash模式可以的,但是url太丑了,没法目视

from vue-cli-multipage.

Deguang avatar Deguang commented on June 24, 2024

@zhenwoo 对,Nginx,做try_files

from vue-cli-multipage.

alvin-xianer avatar alvin-xianer commented on June 24, 2024

怎么配置多页面,多路由,就是多页面就的url是以.html结尾的,现在有需求是/xx.html/a这种怎么配置

from vue-cli-multipage.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.