在 Laravel 5.3 中使用 Vue 组件

Using Vue component in Laravel 5.3

我全新安装了 Laravel 5.3 项目,该项目内置了示例 Vue 组件。

require('./bootstrap');

Vue.component('example', require('./components/Example.vue'));

const app = new Vue({
    el: '#app'
});

然后我尝试添加

<example></example> 

在 welcome.blade.php 中保存了它,但没有任何改变。

我运行gulp看了,我也没改任何JS文件

我错过了什么吗?或者这不是 Vue 组件的工作方式?

您是否在 welcome.blade.php 中添加了 app.js?

<body>
    <div id="app">
        <example></example>
    </div>
    <script src="{{ asset('js/app.js') }}"></script>
</body>

你可能这样做了,但也一定要添加一个元素,其中包含你在 Vue 实例的选项中定义的 ID(在本例中为 #app)。