VUE组件是渲染的,但页面空白.我可以通过检查页面查看代码



我正在用laravel和vue.js制作静态站点。我做

Route::get('/', function () {
    return view('layouts.master');
});

此路线输入代码HERETO负载主页和

import VueRouter from 'vue-router'
import home from './components/home.vue'
import About from './components/About.vue'
import Contact from './components/Contact.vue'
Vue.use(VueRouter)
const routes = [
    { path: '/about', component: About },
    {
        path: '/',
        component: home
    },
    {
        path: '/contact',
        component: Contact
    }
]
const router = new VueRouter({
    mode: 'history',
    routes, // short for `routes: routes`,
})

它是我的appp.js代码。第一次在Localhost上加载页面时:8000主页正常工作,但是当我单击Somme的其他路线并回来时,它不起作用,它显示了空白页面。但是我可以通过检查HTML页面。

听起来history mode在服务器端未正确配置。

作为测试,更改以下内容:

const router = new VueRouter({
    mode: 'history',
    routes, // short for `routes: routes`,
})

...对此:

const router = new VueRouter({
    //mode: 'history',
    routes, // short for `routes: routes`,
})

如果它可以使用,则意味着您的服务器端未正确设置为VUE历史记录模式,您需要配置服务器端以允许使用历史模式。

  • 示例1
  • 示例2 - 向下滚动,向"服务器端"部分的一半多一点

相关内容

最新更新