Vuejs2 Vue路由器在Vue cli生成中不工作
我用vue cli开发了一个项目,在开发模式下运行良好。但是当我建造它的时候。没有路由加载的组件(“/”,组件),一切都很顺利。 我的代码有什么问题Vuejs2 Vue路由器在Vue cli生成中不工作,vuejs2,vue-router,Vuejs2,Vue Router,我用vue cli开发了一个项目,在开发模式下运行良好。但是当我建造它的时候。没有路由加载的组件(“/”,组件),一切都很顺利。 我的代码有什么问题 import Vue from 'vue' import App from './App' import router from './router/index' Vue.config.productionTip = false new Vue({ router, template: '<App/>', component
import Vue from 'vue'
import App from './App'
import router from './router/index'
Vue.config.productionTip = false
new Vue({
router,
template: '<App/>',
components: { App }
}).$mount('#app')
我想你需要处理历史模式的重写工作 检查 nginx:
location / {
try_files $uri $uri/ /index.html;
}
apache(创建/dist/.htaccess)
重新启动发动机
重写基/
重写规则^index\.html$-[L]
重写cond%{REQUEST_FILENAME}-F
重写cond%{REQUEST_FILENAME}-D
重写规则/index.html[L]
在Lumen中添加路由::get('/{vue_capture:[/\w.-]*}',函数(){return view('pages.home');})
在web.php
路由文件的末尾
您可能还想在laracasts上检查此问题找到解决方案了吗?我也有同样的问题:所以基本上你不能在php页面中使用vue路由器,比如说你指的是一个有现有路由的php页面?我想说,无论是现有路由还是不存在路由,您都可以使用vue。这取决于您的设置和需要。也许您可以澄清您的问题?
location / {
try_files $uri $uri/ /index.html;
}
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.html$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.html [L]
</IfModule>