简体   繁体   中英

Vue2 not change in Laravel 5.4

I´m trying to use Vue in Laravel. When I modify example.vue and add it in view, view no change. This is .vue example that Laravel has.

 <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>

I tried to modify this file and run npm run dev , but view no change. ¿Any idea?

You might need to uncomment the require line in your app.js. On Laravel 5.4 it's located in the /resources/assets/js/app.js file.

/**
 * 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'
});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM