|
7 | 7 | CloseIcon as TdCloseIcon, |
8 | 8 | } from 'tdesign-icons-vue'; |
9 | 9 |
|
| 10 | +import log from '../_common/js/log/log'; |
10 | 11 | import { on, off, addClass } from '../utils/dom'; |
11 | 12 | import props from './props'; |
12 | 13 | import { renderTNodeJSX } from '../utils/render-tnode'; |
@@ -74,14 +75,23 @@ export default mixins(getConfigReceiverMixins<Vue, AlertConfig>('alert'), getGlo |
74 | 75 | renderClose(): VNode { |
75 | 76 | const { CloseIcon } = this.useGlobalIcon({ CloseIcon: TdCloseIcon }); |
76 | 77 | let closeContent: ScopedSlotReturnValue = null; |
77 | | - if (this.close === true || this.close === '') { |
| 78 | + // close属性变更为closeBtn过渡期使用,close废弃后可删除。(需兼容标签上直接写close和closeBtn的场景) |
| 79 | + const isUsingClose = Object.prototype.hasOwnProperty.call(this.$vnode.componentOptions.propsData || {}, 'close') |
| 80 | + || this.$scopedSlots.close; |
| 81 | + const closeNode = isUsingClose ? this.close : this.closeBtn; |
| 82 | + if (isUsingClose) { |
| 83 | + log.warnOnce('TAlert', 'prop `close` is going to be deprecated, please use `closeBtn` instead.'); |
| 84 | + } |
| 85 | + if (closeNode === true || closeNode === '') { |
78 | 86 | closeContent = <CloseIcon />; |
79 | | - } else if (typeof this.close === 'string') { |
80 | | - closeContent = this.close; |
81 | | - } else if (typeof this.close === 'function') { |
82 | | - closeContent = this.close(this.$createElement); |
| 87 | + } else if (typeof closeNode === 'string') { |
| 88 | + closeContent = closeNode; |
| 89 | + } else if (typeof closeNode === 'function') { |
| 90 | + closeContent = closeNode(this.$createElement); |
83 | 91 | } else { |
84 | | - closeContent = this.$scopedSlots.close && this.$scopedSlots.close(null)[0]; |
| 92 | + closeContent = isUsingClose ? this.$scopedSlots.close(null)[0] : renderTNodeJSX(this, 'close-btn'); |
| 93 | + // todo 等待renderTNodeJSX修复prop为false时使用slot |
| 94 | + // closeContent = renderTNodeJSX(this, 'closeBtn'); |
85 | 95 | } |
86 | 96 |
|
87 | 97 | return closeContent ? ( |
|
0 commit comments