Vue2在Laravel 5.4中没有变化

时间:2017-03-12 20:40:02

标签: php laravel vue.js

我试图在Laravel中使用Vue。当我修改example.vue并在视图中添加它时,查看没有更改。这是Laravel的例子。

 <template>
    <div class="container">
        <div class="row">
            <div class="col-md-8 col-md-offset-2">
                <div class="panel panel-default">
                    <div class="panel-heading">Example Component</div>

                    <div class="panel-body">
                        I'm an example component!
                    </div>
                </div>
            </div>
        </div>
    </div>
</template>

<script>
    export default {
        mounted() {
            console.log('Component mounted.')
        }
    }
</script>

我尝试修改此文件并运行 npm run dev ,但查看没有更改。 ¿有什么想法吗?

1 个答案:

答案 0 :(得分:0)

您可能需要在app.js中取消注释require行。在Laravel 5.4上,它位于/resources/assets/js/app.js文件中。

/**
 * First we will load all of this project's JavaScript dependencies which
 * includes Vue and other libraries. It is a great starting point when
 * building robust, powerful web applications using Vue and Laravel.
 */

require('./bootstrap');

/**
 * Next, we will create a fresh Vue application instance and attach it to
 * the page. Then, you may begin adding components to this application
 * or customize the JavaScript scaffolding to fit your unique needs.
 */

// Vue.component('example', require('./components/Example.vue'));
// ^^^^^^^^^^^^^^^^^^^^^^ Uncomment this line ^^^^^^^^^^^^^^^^^^^^^^

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