2017-09-15 113 views
-2

我已经使用来构建我改变welcome.blade的例子Vue的文件编制资产就跑laravel 5.5和VUE JS不工作开箱

NPM随后安装由NPM运行看

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

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

,并安装Vue公司开发工具并没有什么正在观看所有

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

+0

控制台说什么?你没有提供足够的信息来帮助你。 –

+0

控制台是空白的,屏幕也是空白的,根本没有任何负载,我已经清空缓存和硬重新加载 – GrahamMorbyDojo

+0

我有与Vue相同的问题,并在控制台中,我可以看到错误“[Vue提醒]:无法安装组件:模板或呈现功能没有定义 在 --->找到 “ –

回答

0

你只需要去</body>标签之前添加 <script src="{{ mix('js/app.js') }}"></script>

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

我希望这会有所帮助。