# 安装前端依赖包
cnpm install
安装Element-ui
使用npm安装,执行命令:cnpm i element-ui -S
在app.js中引入element的组件
import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'
Vue.use(ElementUI)
安装Vue-router组件
cnpm install vue-router --save
实例:
app.js
require('./bootstrap');
window.Vue = require('vue');
import VueRouter from 'vue-router';
Vue.use(VueRouter);
import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';
Vue.use(ElementUI);
import routes from './routes'; // 路由配置文件
// 实例化路由
const router = new VueRouter({
routes
});
// Vue.component('example-component', require('./components/ExampleComponent.vue'));
// Vue.component('a-hello', require('./components/Hello.vue'));
const app = new Vue({
el: '#app',
router
});
/recources/assets/js/routes.js
路由文件
export default[
{ path: '/', component: require('./components/Hello.vue') },
{ path: '/hello', component: require('./components/Hello.vue') },
];
路由访问组件:
<router-view></router-view>
html文件resource/views/index.blade.php
<!doctype html>
<html lang="{{ app()->getLocale() }}">
<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>
<!-- Fonts -->
<link href="https://fonts.googleapis.com/css?family=Raleway:100,600" rel="stylesheet" type="text/css">
</head>
<body>
<div id="app">
<router-view></router-view>
</div>
</body>
<script src="{{ mix('js/app.js') }}"></script>
</html>
网友评论