【发布时间】:2021-04-26 05:28:57
【问题描述】:
为了展示一个产品,我想用这个结构来做链接:
/collections/:slug/:id
到目前为止,我已经创建了这个文件夹结构:
collections/
_category/
_id.vue
_slug.vue
index.vue
_slug.vue 和 index.vue 在 collections 文件夹中。
在本地一切运行正常,但是当我让 npm run dist 和 push to live 时,尝试访问时:
/collections/_category or /collections/_category/_id
没有找到。
我应该进行哪些更改才能使其正常工作?
还有一件事要提的是,当从主页访问产品时,一切正常并且产品已显示,但是当我尝试刷新该页面时,我得到 404 notfound,ngnix。会不会是ngnix的问题? Nginx 配置:
server {
listen 80 default_server;
listen [::]:80 default_server;
root /var/www/{link_to_the_project}/dist;
server_name {mydomainname}.ro;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
}
location ~ /\.ht {
deny all;
}
}
【问题讨论】:
-
尝试
yarn build或yarn generate(如果你要完全静态)然后yarn start看看有什么问题。由于它是本地的,但与生产环境几乎相同,它将帮助您更快地调试它。