Laravel 5.4
とVue JS 2.0
でアプリケーションを作成しようとしていますcomponents
のセットを特定のページでのみ使用していますが、今ではコンポーネントをグローバルに定義していますブレードファイル内のcomponentsタグを使用して、私はロットコンポーネントが役に立たないと言っていたので、私のミックスファイルが大きくなり、これがページレンダリングを遅くするかもしれないと思います。私はブレードファイルでコンポーネントを動的に呼び出すことができるソリューションを探しています。私は、次のHTMLコードを持ってmaster blade
ファイルましlaravelでVue JSで動的コンポーネントを呼び出す
Vue.component('NavBar', require('./components/NavBar.vue'));
Vue.component('HomeBanner', require('./components/HomeBanner.vue'));
Vue.component('PageFooter', require('./components/Footer.vue'));
Vue.component('Categories', require('./components/Categories.vue'));
Vue.component('SubCategory', require('./components/SubCategory.vue'));
const app = new Vue({
el: '#app'
});
:以下は私のapp.js
ファイルです
<div id="app">
<nav-bar></nav-bar>
@yield('content')
<div class="clearfix"></div>
<page-footer></page-footer>
</div>
<!-- Core Scripts for Vue Components -->
<script src="{{ asset('js/app.js') }}"></script>
をしてindex.blade.php
に仮定をIまし
@extends('layouts.master')
@section('title', 'HomePage')
@section('content')
<home-banner></home-banner>
@endsection
とcategories
ページで私は持っている:
@extends('layouts.master')
@section('title', 'Select your category')
@section('content')
<categories></categories>
@endsection
これを達成する方法を教えてください。