无法执行' createElement' on' Document'提供的代码名称(' {{laravue.currentview}}')不是有效名称

时间:2018-03-22 14:08:41

标签: laravel-5 vue.js

我使用这个库https://github.com/laravue/laravue, 但当我将它运行到我的本地时,它会显示错误:

  

未捕获DOMException:无法执行' createElement'上   '文档':提供的标记名称(' {{laravue.currentview}}')不是   一个有效的名字。

这是我的app.blade.php:

<div class="container" id="app">
        <div class="content">
            <component is="@{{laravue.currentView }}" v-bind:app="laravue.app" keep-alive></component>
        </div>
    </div>
    <script defer="defer" src="/js/bundle.js"></script>

我的App.js

var Vue = require('vue')
// Vue.use(require('vue-resource'))
// Vue.use(require('vue-validator'))
// Vue.use(requrie('vue-router'))
Vue.config.debug = true // Comment this line for production

new Vue({
    el: '#app',
    created: function() {
        this.laravue.init.call(this, ['home']);
    },
    data: {
        laravue: require('./laravue.coffee')
    },
    components: require('./components.coffee') // You can just inline them, but I recommend putting them in their own file
})

components.coffee:

module.exports =
    # Custom Elements
    'titles': require './components/title.coffee'
    'random-quote': require './components/random-quote.coffee'

    # Views
    'home-view': require './views/home.coffee'

home.coffee:

module.exports =
    ready: () -> require('../view-ready.coffee').call(this)
    props: ['app']
    template: require('./home.template.html')

这里是我的home.template.html:

<title>Laravue {{app.laravue.version }}</title>
<random-quote></random-quote>

1 个答案:

答案 0 :(得分:0)

似乎由于某种原因通过is="{{laravue.currentView }}"进行绑定 正在被vue JS弃用。您需要从

更改代码
<component is="@{{laravue.currentView }}" v-bind:app="laravue.app" keep-alive></component>

<component v-bind:is="laravue.currentView" v-bind:app="laravue.app" keep-alive></component>

您可以找到here called Dynamic Components

:d