laravel+vue+vue-router无法显示页面
laravel
路由:
Route::get('/', function () {
return view('welcome');
});
asset
目录结构:
app.js
文件代码:
require('./bootstrap');
window.Vue = require('vue');
import router from './router';
const app = new Vue({
el: '#app',
router
});
router/index.js
文件代码:
import Vue from 'vue';
import VueRouter from 'vue-router';
import routes from './router';
Vue.use(VueRouter);
const router = new VueRouter({
mode: 'history',
routes
});
router.beforeEach((to, from, next) => {
});
router.afterEach(() => {
});
export default router;
router/router.js
文件代码:
import index from '../page/index';
import user from '../page/user';
const visitor = [
{
name: 'index',
path: '/',
component: index
}
];
const member = [
{
path: '/user',
component: user
}
];
export default [
...visitor,
...member
];
welcome.blade.php
文件代码:
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="csrf-token" content="{{ csrf_token() }}">
<title>Laravel</title>
<link href="{{ mix('/css/app.css') }}" rel="stylesheet">
</head>
<body>
<div id="app">
<router-view></router-view>
</div>
</body>
<script src="{{ mix('/js/app.js') }}"></script>
</html>
page/index.vue
文件代码:
<template>
<div>这是首页{{name}}</div>
</template>
<script>
export default {
data: function(){
return {
name: 'wwww',
}
},
mounted() {
console.log('Component mounted.')
}
}
</script>
现在问题是访问首页运行不报错,但是页面是空白的
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
原因找到了,已经搞定了