javascript - 多布局 Laravel 和 Vuejs
问题描述
当我只使用 laravel 时,很容易创建一个具有 2 种不同设计的站点,例如使用 AdminLte https://adminlte.io/themes/AdminLTE/index.html的管理面板 和使用此设计的主站点http://venoxis .epizy.com/project/
使用刀片很容易,我创建了一个名为 (admin) 的文件夹,其中包含文件(layout.blade.php、index.blade.php ..etc)该文件夹内的所有文件都从layout.blade.php扩展:
<!doctype html>
<html lang="{{ str_replace('_', '-', app()->getLocale()) }}">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- CSRF Token -->
<meta name="csrf-token" content="{{ csrf_token() }}">
<title>{{ config('app.name', 'Laravel') }}</title>
<!-- Fonts -->
<link rel="dns-prefetch" href="//fonts.gstatic.com">
<link href="https://fonts.googleapis.com/css?family=Nunito" rel="stylesheet">
<!-- Styles -->
<link href="{{ asset('css/app.css') }}" rel="stylesheet">
@yield('styles')
</head>
<body>
<div id="app">
@include('layouts.navbar');
<main class="py-4">
@yield('content')
</main>
</div>
<!-- Scripts -->
<script src="{{ asset('js/app.js') }}" defer></script>
@yield('scripts')
</body>
</html>
所以现在我已经准备好管理面板布局,每个页面都有自己的标题(样式和标题)、脚本和内容
现在我正在使用 laravel 和 vuejs 制作单页应用程序,我该怎么做?我制作了App.vue
<template>
<div>
<router-view></router-view>
</div>
</template>
<script>
export default {
name: "App"
}
</script>
<style scoped>
</style>
应用程序.js
require('./bootstrap');
import Vue from 'vue';
import router from './router';
import App from './components/App';
import BootstrapVue from 'bootstrap-vue';
import ExampleComponent from "./components/ExampleComponent";
import Login from "./components/Login";
import Dashboard from "./components/admin/Dashboard";
const routes = [
{path: '/', component: ExampleComponent},
{path:'/login', component: Login},
{path:'/admin', component: Dashboard}
]
const router = new VueRouter({
routes,
mode: 'history',
});
Vue.use(BootstrapVue);
const app = new Vue({
el: '#app',
components: {
App
},
router,
});
解决方案
推荐阅读
- docker - Docker + Rancher 上下文中的主机是什么?
- r - 过滤器语句中的错误 - 闪亮的应用程序
- ios - CLPlacemark 没有成员“获取”
- python - ImportError: DLL 加载失败: El sistema operativo no puede ejecutar %1
- pvlib - 如何从 GHI 估计直接水平辐照度
- python - Python:如何在 Selenium 中隐藏输出的 Chrome 消息?
- c++ - C ++ Singleton被实例化两次 - 静态成员变量的问题
- go - 不使用“go env”中指定的 $GOPATH
- wordpress - $wpdb-> 使用 WordPress 短代码插入
- javascript - 使用 Vue js 2.5 将我的项目移动到子文件夹中时,为什么 App 容器为空?