php - Laravel5.2+vue2.0使用组件报错
黄舟
黄舟 2017-04-11 10:22:00
0
1
635

1.blade文件代码如下:

<ul class="list-group">
    <step-list v-for="step in inProcess" v-bind:step="step"></step-list>
</ul>

2.js代码如下:

3.vue文件代码如下:

4.最后面报错如下:

[Vue warn]: You are using the runtime-only build of Vue where the template compiler is not available. Either pre-compile the templates into render functions, or use the compiler-included build. 
(found in <Root>)

请大神解答,百度了很久都没找到问题,代码全部仔细看了一遍也没找到问题,跪求解答,谢谢!!!

黄舟
黄舟

人生最曼妙的风景,竟是内心的淡定与从容!

reply all(1)
伊谢尔伦

话说你都是使用webpack来编译打包vue文件了吧?为啥还要把#app的模版放在blade模版中?

有两种解决方法:

第一种: 使用非esm版本的vue -- 把webpack配置文件(如 webpack.base.conf.js)中的 vue$` 的 alias
干掉

resolve: {
  alias: {
    'vue$': 'vue/dist/vue.esm.js',  // --> 这一行注释掉
    //...
  }
}

然后重新构建应该就OK了。

第二种:把blade中的#app的内容拷贝出来,放到 new Vue({el:'#app'}) 中的template位置,比如:

new Vue({
   el: '#app',

// 把blade中的#app的内容拷贝到template中:
   template: `
<p id="app">
<ul class="list-group">
    <step-list v-for="step in inProcess" v-bind:step="step"></step-list>
</ul>
</p>
`,

   //...
})
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!