【问题标题】:Direct url not working in vuejs but router push works直接 url 在 vuejs 中不起作用,但路由器推送有效
【发布时间】:2018-10-10 06:34:03
【问题描述】:

当我使用this.$router.push() 加载组件localhost:8080/scan 时,url 与组件一起加载但是当我执行npm run build 然后http-server dist/ 时,url localhost:8080/scan 不起作用,给出 404。 知道为什么它在开发中起作用而不是在构建之后起作用。 我确实在网上查了一下,发现这是一个 nginx 问题,但我尝试按照这个文档添加try_files $uri $uri/ /index.html;https://router.vuejs.org/en/essentials/history-mode.html,但似乎没有任何效果。非常感谢任何帮助。

【问题讨论】:

    标签: javascript node.js vue.js vue-router


    【解决方案1】:

    请将您的完整代码发布到问题或 github 存储库。否则很难猜出你的问题是什么。

    如果我不得不猜测 - 你的 http-server 找不到 scan.html 因为它不存在。您有几个选择:

    【讨论】:

      猜你喜欢
      • 2018-09-23
      • 2021-04-25
      • 2020-05-20
      • 2021-11-15
      • 2016-01-10
      • 2013-12-25
      • 2020-01-15
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多