在TDesign中使用notify 报错[Vue warn]: Invalid prop: custom validator check failed for prop “theme“. 解决方法

之前我们用 ElementUI
就是直接

this.$notify({
  title: '提示',
  message: '这是一条通知消息',
  type: 'success'
})

但如果你在 TDesign 中这样写就会报错
在TDesign中使用notify 报错[Vue warn]: Invalid prop: custom validator check failed for prop “theme“. 解决方法_第1张图片
这个问题是比较奇葩的直到我打开node_modules查看他的代码 原来
就和文档中整个的提示语法基本是一样的
在TDesign中使用notify 报错[Vue warn]: Invalid prop: custom validator check failed for prop “theme“. 解决方法_第2张图片
这里可以看出 他需要三个参数 分别是
theme 提示类型
title 标题
content 提示内容
而他的notify接受两个参数 第一个是 theme
第二个是配置对象 可以包含 title 和 content
所以 我们可以将代码改成这样

this.$notify('success',{
	title: "操作提示",
	content: "这是一条普通的消息通知"
});

这样 我们的代码就正常跑起来了
在TDesign中使用notify 报错[Vue warn]: Invalid prop: custom validator check failed for prop “theme“. 解决方法_第3张图片

你可能感兴趣的:(tdesign,vue.js,前端)