2017-11-18 153 views
0

我使用这个库VUE-通知:https://github.com/cristijora/vue-notifyjsVue的组件没有渲染

上述页面状态的文档:component: { //is rendered instead of notification message因此我想给它动力组件,这样我可以处理自定义事件。这是我的代码:

Vue.use(vueNotifyjs) 
new Vue({ 
    el: '#app', 

    methods: { 
    addNotification(verticalAlign = 'top', horizontalAlign = 'right') { 
     this.$notify({ 
     component: function(){ 
      return { 
      template: '<h1>Hello</h1>' 
      }; 
     }, 
     horizontalAlign: horizontalAlign, 
     verticalAlign: verticalAlign, 
     type: "success" 
     }) 
    } 
    } 
}) 

这是我的jsfiddle:https://jsfiddle.net/z11fe07p/2706/

但这个词Hello未在通知得到呈现。任何想法我错过了什么?

回答

1

我认为组件键应该有一个Vue组件的实例。 在您的情况,如下

Vue.component('custom-message',{ template:`<div>Hello World</div>` })

我已经在这个link修改摆弄上面创建VUE组件。

希望它有帮助

+0

好bhai。谢谢。 –