[英]Vue Component not rendering vue-notify
我正在使用这个库: https : //github.com/cristijora/vue-notifyjs
上一页上的文档指出: 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
”一词。 有什么想法我想念的吗?
我认为组件键应具有Vue Component的实例。 在您的方案中,创建一个vue组件,如下所示
Vue.component('custom-message',{ template:`<div>Hello World</div>` })
我在此链接中用上面的方法修改了小提琴。
希望能帮助到你
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.