今天早上折腾配置了nginx,目录是指向成功了.但是 /#/ 一直去不掉, 求大神指点,
Vue的peizhi
new Vue({
el: '#app',
mode: 'history',
router,
template: '<App/>',
components: {App}
})
这是我的nginx 配置 ,
server {
listen 80;
server_name hello.com ;
root "C:/www/Aweb/vr29/public_html";
location / {
index index.html index.htm index.php;
#autoindex on;
}
location /start {
try_files $uri $uri/ /index.html;
rewrite ^/start/(.*)$ /app/public/start/dist/index.html last;
}
location ~ \.php(.*)$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_split_path_info ^((?U).+\.php)(/?.+)$;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
include fastcgi_params;
}
}
这个我已经知道了,我的
mode: 'history',
写错了地方,
现在问题是 ,我已经指向过去了,
但是我后面不管输入什么只是在打开 App.vue 里面的内容,
理由里面的内容不显示
我配置的路由失效了.
现在nginx的配置
server {
listen 80;
server_name hello.com ;
root "C:/www/Aweb/vr29/public_html";
location / {
index index.html index.htm index.php;
#autoindex on;
}
location /start {
try_files $uri $uri/ /index.html?$args;
rewrite ^/start/(.*)$ /app/public/start/dist/index.html last;
}
location = /demo {
#try_files $uri $uri/ /app/public/start/dist/index.html =404;
try_files $uri $uri/ /index.html?$args;
}
location ~ \.php(.*)$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_split_path_info ^((?U).+\.php)(/?.+)$;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
include fastcgi_params;
}
}
使用 : http://hello.com/start,打开编译后的项目,
我现在路由中,有一个Home
export default new Router({
mode: 'history',
routes: [
{
path: '/',
name: 'Hello',
component: Hello
},
{
path: '/home',
name: 'Home',
component: Home
},
{
path: '/user',
name: 'User',
component: User
}
]
})
我访问 http://hello.com/start/home
进不去 home组件里
在开发的时候就可以把#去掉了,试试把mode:history写到router里面去,然后重新打包发到服务器
例如
vue-router文档
上面文档链接的内容
nginx