diff --git a/components.js b/components.js index c0c25f949..e00d27f28 100644 --- a/components.js +++ b/components.js @@ -31,4 +31,5 @@ module.exports = [ 'pagination', 'sidebar', 'tree-select', + 'notice-bar', ]; diff --git a/src/notice-bar/index.js b/src/notice-bar/index.js index 83db62c64..945f80586 100644 --- a/src/notice-bar/index.js +++ b/src/notice-bar/index.js @@ -37,9 +37,13 @@ export default createComponent({ }, watch: { - scrollable: 'start', + scrollable() { + this.start(); + }, text: { - handler: 'start', + handler() { + this.start(); + }, immediate: true, }, }, @@ -105,7 +109,8 @@ export default createComponent({ }, render() { - const { slots, mode, leftIcon, onClickIcon } = this; + const slots = this.$slots; + const { mode, leftIcon, onClickIcon } = this; const barStyle = { color: this.color, @@ -118,10 +123,8 @@ export default createComponent({ }; function LeftIcon() { - const slot = slots('left-icon'); - - if (slot) { - return slot; + if (slots['left-icon']) { + return slots['left-icon'](); } if (leftIcon) { @@ -130,10 +133,8 @@ export default createComponent({ } function RightIcon() { - const slot = slots('right-icon'); - - if (slot) { - return slot; + if (slots['right-icon']) { + return slots['right-icon'](); } let iconName; @@ -175,7 +176,7 @@ export default createComponent({ style={contentStyle} onTransitionend={this.onTransitionEnd} > - {this.slots() || this.text} + {slots.default?.() || this.text} {RightIcon()} diff --git a/vant.config.js b/vant.config.js index 23801ec26..b9f626054 100644 --- a/vant.config.js +++ b/vant.config.js @@ -253,10 +253,10 @@ module.exports = { // path: 'list', // title: 'List 列表', // }, - // { - // path: 'notice-bar', - // title: 'NoticeBar 通知栏', - // }, + { + path: 'notice-bar', + title: 'NoticeBar 通知栏', + }, { path: 'progress', title: 'Progress 进度条', @@ -587,10 +587,10 @@ module.exports = { // path: 'list', // title: 'List', // }, - // { - // path: 'notice-bar', - // title: 'NoticeBar', - // }, + { + path: 'notice-bar', + title: 'NoticeBar', + }, { path: 'progress', title: 'Progress',