首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在laravel的vue js中处于历史模式时,组件未加载。

在laravel的vue js中处于历史模式时,组件未加载。
EN

Stack Overflow用户
提问于 2018-05-09 01:58:40
回答 1查看 315关注 0票数 0

当我将模式更改为历史时,URL中的散列将被删除,但组件不会加载。这是app.js

代码语言:javascript
复制
window.Vue = require('vue');
import VueRouter from 'vue-router';



var index = Vue.component('index', 
require('./components/frontend/testingIndexComponent.vue'));
var component1 = Vue.component('component1', 
require('./components/frontend/testingComponent.vue'));


Vue.use(VueRouter);

const router = new VueRouter({
mode: 'history',    
routes: [
  { path: '/', component: index },
  { path: '/component1', component: component1 }
]
})
const app = new Vue({
router
}).$mount('#app')

这是web.php

代码语言:javascript
复制
Route::get('/{vue_capture?}', function () {
return view('index4');
})->where('vue_capture', '[\/\w\.-]*');

这是index4.blade.php

代码语言:javascript
复制
<body>
  <div>
    <h1>Header</h1>
        <!-- <a><router-link tag="li" to="projects">
            sdds
        </router-link></a> -->
</div>
<div id="app">
    <a><router-link  to="component1">
            sddsdadadssa
        </router-link></a>
    <router-view>

    </router-view>
</div>
<div>
    <h1>Footer</h1>
</div>
<script type="text/javascript" src="{{URL::to('public/js/app.js')}}"> 
</script>
EN

回答 1

Stack Overflow用户

发布于 2020-08-13 03:13:57

删除

代码语言:javascript
复制
mode: 'history'

并使用

代码语言:javascript
复制
hashbang: false,
history: true

相反,

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/50239649

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档