我是Vue的新手,截至目前我正在使用Vue 1.0。在我的laravel app vue组件没有加载。我也没有在Vue devtool或chrome devtool中出现任何错误。这是我的代码:
我的master.blade.php布局:
<!DOCTYPE html>
<html>
<head>
<title>Vue</title>
</head>
<body>
<div id="app">
<component is="{{ $vueView }}">
@yield('content')
</component>
</div>
<script src="{{ asset('js/main.js') }}"></script>
</body>
</html>
我的about_page.blade.php
@extends('layouts.master', ['vueView' => 'AboutView'])
@section('content')
<h2>About View</h2>
@endsection
我的home_page.blade.php
@extends('layouts.master', ['vueView' => 'HomeView'])
@section('content')
<h2>Home View</h2>
@endsection
我的资源/资产/ js / dynamic_components.js
// Browserify Entrypoint
import Vue from 'vue';
import HomeView from './components/HomeView.vue';
import AboutView from './components/AboutView.vue';
new Vue({
el: '#app',
components: {
HomeView, AboutView
}
});
我的/resources/assets/js/components/AboutView.vue
<template>
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Atque placeat, quis maiores sequi inventore, voluptatibus labore hic fugit, autem consequuntur ipsum ex laudantium. Accusamus optio veniam velit, laudantium. Odit, facilis.
</template>
<script>
export default {
ready() {
alert('home view is ready');
}
}
</script>
我的/resources/assets/js/components/HomeView.vue
<script>
export default {
created() {
alert('Welcome to the Home Page');
}
}
</script>
我的routes.php
Route::get('/home-view', function () {
return view('home_view');
});
Route::get('/about-view', function () {
return view('about_view');
});
我的gulpfile.js
var elixir = require('laravel-elixir');
require('laravel-elixir-vueify');
elixir(function(mix) {
mix.browserify(['main.js', 'dynamic_components.js']);
});
所有内容分别来自h2
和home_page.blade.php
的{{1}}。我哪里错了???
about_page.blade.php
答案 0 :(得分:0)
完成。我重新安装了这个项目。它现在正在运作。 抱歉,麻烦。