Commit efc65a34ff9773901c55ed41e760fa4df9fc69ff

Authored by zhigang.li
1 parent 6b2cd674

fixed bug of notice when has render and title bug no desc

examples/routers/notice.vue
... ... @@ -6,6 +6,7 @@
6 6 <Button @click="success(false)">成功</Button>
7 7 <Button @click="warning(false)">警告</Button>
8 8 <Button @click="error(false)">错误</Button>
  9 + <Button @click="testRender()">render</Button>
9 10 <p>仅标题</p>
10 11 <Button @click="info(true)">消息</Button>
11 12 <Button @click="success(true)">成功</Button>
... ... @@ -54,7 +55,7 @@
54 55 warning (nodesc) {
55 56 this.$Notice.warning({
56 57 title: '这是通知标题',
57   - desc: nodesc ? '' : '这里是通知描述这里,是通知描述这里是通知描述这里,是通知描述这里,是通知描述这里是通知描述这里是通知描述'
  58 + desc: nodesc ? '' : '这里是通知描述这里,是通知描述这里是通知描述这里,是通知描述这里,是通知描述这里是通知描述这里是通知描述',
58 59 });
59 60 },
60 61 error (nodesc) {
... ... @@ -63,6 +64,20 @@
63 64 desc: nodesc ? '' : '这里是通知描述这里,是通知描述这里是通知描述这里,是通知描述这里,是通知描述这里是通知描述这里是通知描述'
64 65 });
65 66 },
  67 + testRender () {
  68 + this.$Notice.info({
  69 + title: '这是通知标题',
  70 + duration: 0,
  71 + // desc: '当你定义了render之后,这个描述会被覆盖',
  72 + render: h => {
  73 + return h('span', {}, [
  74 + '这是',
  75 + h('Button', {props: {type: 'text'}}, 'render'),
  76 + '函数渲染的'
  77 + ]);
  78 + },
  79 + });
  80 + },
66 81 destroy () {
67 82 this.$Notice.destroy();
68 83 }
... ...
src/components/notice/index.js
... ... @@ -45,7 +45,7 @@ function notice (type, options) {
45 45  
46 46 let withIcon;
47 47  
48   - const with_desc = (options.render && !title) ? '' : desc === '' ? '' : ` ${prefixCls}-with-desc`;
  48 + const with_desc = (options.render && !title) ? '' : (desc || options.render) ? ` ${prefixCls}-with-desc` : '';
49 49  
50 50 if (type == 'normal') {
51 51 withIcon = false;
... ...