问题:
访问 http://xx/landf/ 正常
访问 http://xx/landf/index.html 没有渲染
访问 http://xx/others 没有渲染
在 vue 中点击链接跳转正常,直接输入 vue 路由链接 没有渲染
配置参考的网上的。。。 请问这是什么原因呢?
nginx 配置如下:
location /landf/ { root /home/ubuntu/python/lost_found/web/; index index.html index.htm; } location / { try_files $uri $uri/ /landf/index.html; index index.html; }
![]() | 1 Pastsong 2017-10-07 22:45:12 +08:00 vue 这种框架在后端只有一个入口(除 ssr ),所有路径都返回 index.html 就好了 |
![]() | 4 Trim21 2017-10-07 23:20:00 +08:00 try_files /landf/index.html; |
![]() | 5 gogobody OP @Trim21 这样写 给了一个错 nginx: [emerg] invalid number of arguments in "try_files" directive in /etc/nginx/conf.d/lostandfound.conf:26 |
![]() | 6 Trim21 2017-10-08 00:44:54 +08:00 @gogobody 啊啊啊啊抱歉说错了 访问 http://xx/others 没有渲染是因为 index.html 请求成功,但是 /static/文件夹里的 js,css 之类的请求失败了 其实不需要配置 landf 那一项,直接这样 location / { root /home/ubuntu/python/lost_found/web/; index inex.html; try_files $uri $uri/ /index.html; } |
![]() | 7 Trim21 2017-10-08 01:01:12 +08:00 root /home/ubuntu/python/lost_found/web/landf/; |
![]() | 8 gogobody OP @Trim21 感谢,已经关了电脑了,明天再试试,主要是我想把配置在 /land/路径下,而不是根路径 |
![]() | 11 Trim21 2017-10-08 01:32:45 +08:00 @gogobody 感觉 history 模式挂载在目录下挺蛋疼的...要自己手动在 path 前面都加上路径 是不是我姿势不太对...有什么相应的设置吗 |
![]() | 12 Trim21 2017-10-08 01:39:41 +08:00 @Trim21 有点词不达意...原来在 vue-router 里面设置了 path:"/index"为了挂载到 sub 目录下面好像只能手动改成 path:"/sub/index.." |
![]() | 13 gogobody OP @Trim21 我是看了 https://www.zhihu.com/question/46630687 这个二楼配置的,不知道为什么效果不一样 |