2017-11-18 353 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。謝謝。 –