fix: add info prop deprecation warning (#7352)

This commit is contained in:
neverland 2020-10-16 20:52:19 +08:00 committed by GitHub
parent 3fe485c959
commit 7d0f4fc9ed
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 35 additions and 0 deletions

View File

@ -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 (
<div class={bem('icon')}>

View File

@ -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 (
<div class={bem('icon-wrapper')}>

View File

@ -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 (
<a
class={bem({ select: this.select, disabled: this.disabled })}

View File

@ -11,6 +11,7 @@ export default createComponent({
...routeProps,
dot: Boolean,
name: [Number, String],
// @deprecated
info: [Number, String],
badge: [Number, String],
title: String,
@ -57,6 +58,12 @@ export default createComponent({
const { slots, parent, isActive } = this;
const slotContent = slots();
if (process.env.NODE_ENV !== 'production' && this.info) {
console.warn(
'[Vant] Tab: "info" prop is deprecated, use "badge" prop instead.'
);
}
if (!slotContent) {
return;
}

View File

@ -19,6 +19,7 @@ export default createComponent({
dot: Boolean,
icon: String,
name: [Number, String],
// @deprecated
info: [Number, String],
badge: [Number, String],
iconPrefix: String,
@ -67,6 +68,12 @@ export default createComponent({
const active = this.parent.route ? this.routeActive : this.active;
const color = this.parent[active ? 'activeColor' : 'inactiveColor'];
if (process.env.NODE_ENV !== 'production' && this.info) {
console.warn(
'[Vant] TabbarItem: "info" prop is deprecated, use "badge" prop instead.'
);
}
return (
<div class={bem({ active })} style={{ color }} onClick={this.onClick}>
<div class={bem('icon')}>