今天早上折腾配置了nginx,目录是指向成功了.但是/#/一直去不掉,求大神指点,
Vue的peizhi
newVue({el:'#app',mode:'history',router,template:'',components:{App}})
这是我的nginx配置,
server{listen80;server_namehello.com;root"C:/www/Aweb/vr29/public_html";location/{indexindex.htmlindex.htmindex.php;#autoindexon;}location/start{try_files$uri$uri//index.html;rewrite^/start/(.*)$/app/public/start/dist/index.htmllast;}location~\.php(.*)${fastcgi_pass127.0.0.1:9000;fastcgi_indexindex.php;fastcgi_split_path_info^((?U).+\.php)(/?.+)$;fastcgi_paramSCRIPT_FILENAME$document_root$fastcgi_script_name;fastcgi_paramPATH_INFO$fastcgi_path_info;fastcgi_paramPATH_TRANSLATED$document_root$fastcgi_path_info;includefastcgi_params;}}
这个我已经知道了,我的
mode:'history',
写错了地方,
现在问题是,我已经指向过去了,
但是我后面不管输入什么只是在打开App.vue里面的内容,
理由里面的内容不显示
我配置的路由失效了.
现在nginx的配置
server{
listen80;server_namehello.com;root"C:/www/Aweb/vr29/public_html";location/{indexindex.htmlindex.htmindex.php;#autoindexon;}location/start{try_files$uri$uri//index.html?$args;rewrite^/start/(.*)$/app/public/start/dist/index.htmllast;}location=/demo{#try_files$uri$uri//app/public/start/dist/index.html=404;try_files$uri$uri//index.html?$args;}location~\.php(.*)${fastcgi_pass127.0.0.1:9000;fastcgi_indexindex.php;fastcgi_split_path_info^((?U).+\.php)(/?.+)$;fastcgi_paramSCRIPT_FILENAME$document_root$fastcgi_script_name;fastcgi_paramPATH_INFO$fastcgi_path_info;fastcgi_paramPATH_TRANSLATED$document_root$fastcgi_path_info;includefastcgi_params;}
}
使用:http://hello.com/start,打开编译后的项目,
我现在路由中,有一个Home
exportdefaultnewRouter({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里面去,然后重新打包发到服务器
例如
constrouter=newVueRouter({mode:'history',routes:[...]})
上面文档链接的内容
nginx
location/{try_files$uri$uri//index.html;}