laravel 5.5和vue js没有开箱即用

时间:2017-09-15 07:36:01

标签: javascript laravel-5 vue.js vuejs2

我已编译资产并运行

npm install后跟npm run watch

使用构建的示例Vue文件,我将welcome.blade更改为

<body>
    <div id="app">
        <Example></Example>
    </div>

    <script href="{{URL::asset('js/app.js')}}" charset="utf-8"></script>
    </body>
</html>

并且还安装了Vue dev工具,而且根本没有查看任何内容

Example.vue

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

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');

window.Vue = require('vue');

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

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

What I get on page load

1 个答案:

答案 0 :(得分:2)

你只需要添加 在---------------------------------------------- |job_id |name |skills | ---------------------------------------------- |1 |Job 1 |[1] | |3 |Job 3 |[4,5,6] | ---------------------------------------------- 标记之前<script src="{{ mix('js/app.js') }}"></script>

通过这种方式添加包含Vue库,组件等的混合。

我希望这有帮助。