From 7d0f4fc9ed345fec49f202c1521217bded455b56 Mon Sep 17 00:00:00 2001 From: neverland Date: Fri, 16 Oct 2020 20:52:19 +0800 Subject: [PATCH] fix: add info prop deprecation warning (#7352) --- src/goods-action-icon/index.js | 7 +++++++ src/grid-item/index.js | 7 +++++++ src/sidebar-item/index.js | 7 +++++++ src/tab/index.js | 7 +++++++ src/tabbar-item/index.js | 7 +++++++ 5 files changed, 35 insertions(+) diff --git a/src/goods-action-icon/index.js b/src/goods-action-icon/index.js index dff2a5ff6..36df3e8d3 100644 --- a/src/goods-action-icon/index.js +++ b/src/goods-action-icon/index.js @@ -15,6 +15,7 @@ export default createComponent({ text: String, icon: String, color: String, + // @deprecated info: [Number, String], badge: [Number, String], iconClass: null, @@ -30,6 +31,12 @@ export default createComponent({ const slot = this.slots('icon'); const info = this.badge ?? this.info; + if (process.env.NODE_ENV !== 'production' && this.info) { + console.warn( + '[Vant] GoodsActionIcon: "info" prop is deprecated, use "badge" prop instead.' + ); + } + if (slot) { return (
diff --git a/src/grid-item/index.js b/src/grid-item/index.js index 3ced482e4..1622e0131 100644 --- a/src/grid-item/index.js +++ b/src/grid-item/index.js @@ -21,6 +21,7 @@ export default createComponent({ text: String, icon: String, iconPrefix: String, + // @deprecated info: [Number, String], badge: [Number, String], }, @@ -73,6 +74,12 @@ export default createComponent({ const iconSlot = this.slots('icon'); const info = this.badge ?? this.info; + if (process.env.NODE_ENV !== 'production' && this.info) { + console.warn( + '[Vant] GridItem: "info" prop is deprecated, use "badge" prop instead.' + ); + } + if (iconSlot) { return (
diff --git a/src/sidebar-item/index.js b/src/sidebar-item/index.js index 058eb77d5..46f99d60e 100644 --- a/src/sidebar-item/index.js +++ b/src/sidebar-item/index.js @@ -11,6 +11,7 @@ export default createComponent({ props: { ...routeProps, dot: Boolean, + // @deprecated info: [Number, String], badge: [Number, String], title: String, @@ -37,6 +38,12 @@ export default createComponent({ }, render() { + if (process.env.NODE_ENV !== 'production' && this.info) { + console.warn( + '[Vant] SidebarItem: "info" prop is deprecated, use "badge" prop instead.' + ); + } + return (