我使用这个库https://github.com/laravue/laravue,但是当我将它运行到本地时,它会显示错误:
Uncaught :未能在“文档”上执行“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>发布于 2018-04-02 00:51:45
由于某种原因,vue JS不推荐通过is="{{laravue.currentView }}"进行绑定。您需要将代码更改为
<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>你可以找到这里称为动态组件
:D
https://stackoverflow.com/questions/49430791
复制相似问题