diff --git a/src/collapse-item/index.js b/src/collapse-item/index.js
index 25826cde8..f84910079 100644
--- a/src/collapse-item/index.js
+++ b/src/collapse-item/index.js
@@ -1,5 +1,5 @@
// Utils
-import { createNamespace, isDef } from '../utils';
+import { createNamespace } from '../utils';
import { raf, doubleRaf } from '../utils/dom/raf';
// Mixins
@@ -35,7 +35,7 @@ export default createComponent({
computed: {
currentName() {
- return isDef(this.name) ? this.name : this.index;
+ return this.name ?? this.index;
},
expanded() {
diff --git a/src/goods-action-icon/index.js b/src/goods-action-icon/index.js
index b9bb118dc..dff2a5ff6 100644
--- a/src/goods-action-icon/index.js
+++ b/src/goods-action-icon/index.js
@@ -1,4 +1,4 @@
-import { createNamespace, isDef } from '../utils';
+import { createNamespace } from '../utils';
import { route, routeProps } from '../utils/router';
import { ChildrenMixin } from '../mixins/relation';
import Info from '../info';
@@ -28,7 +28,7 @@ export default createComponent({
genIcon() {
const slot = this.slots('icon');
- const info = isDef(this.badge) ? this.badge : this.info;
+ const info = this.badge ?? this.info;
if (slot) {
return (
diff --git a/src/grid-item/index.js b/src/grid-item/index.js
index ca44c7da7..3ced482e4 100644
--- a/src/grid-item/index.js
+++ b/src/grid-item/index.js
@@ -1,5 +1,5 @@
// Utils
-import { createNamespace, addUnit, isDef } from '../utils';
+import { createNamespace, addUnit } from '../utils';
import { BORDER } from '../utils/constant';
import { route, routeProps } from '../utils/router';
@@ -71,7 +71,7 @@ export default createComponent({
genIcon() {
const iconSlot = this.slots('icon');
- const info = isDef(this.badge) ? this.badge : this.info;
+ const info = this.badge ?? this.info;
if (iconSlot) {
return (
diff --git a/src/icon/index.tsx b/src/icon/index.tsx
index 7c087e6f4..d9962dfa1 100644
--- a/src/icon/index.tsx
+++ b/src/icon/index.tsx
@@ -1,5 +1,5 @@
// Utils
-import { createNamespace, addUnit, isDef } from '../utils';
+import { createNamespace, addUnit } from '../utils';
import { inherit } from '../utils/functional';
// Components
@@ -64,10 +64,7 @@ function Icon(
>
{slots.default && slots.default()}
{imageIcon &&
}
-
+
);
}
diff --git a/src/picker/index.js b/src/picker/index.js
index 004b8599a..96cbf07ba 100644
--- a/src/picker/index.js
+++ b/src/picker/index.js
@@ -1,5 +1,5 @@
// Utils
-import { createNamespace, isDef } from '../utils';
+import { createNamespace } from '../utils';
import { preventDefault } from '../utils/dom/event';
import { BORDER_UNSET_TOP_BOTTOM } from '../utils/constant';
import { pickerProps, DEFAULT_ITEM_HEIGHT } from './shared';
@@ -86,9 +86,7 @@ export default createComponent({
let cursor = { children: this.columns };
while (cursor && cursor.children) {
- const defaultIndex = isDef(cursor.defaultIndex)
- ? cursor.defaultIndex
- : +this.defaultIndex;
+ const defaultIndex = cursor.defaultIndex ?? +this.defaultIndex;
formatted.push({
values: cursor.children,
@@ -328,9 +326,7 @@ export default createComponent({
allowHtml={this.allowHtml}
className={item.className}
itemHeight={this.itemPxHeight}
- defaultIndex={
- isDef(item.defaultIndex) ? item.defaultIndex : +this.defaultIndex
- }
+ defaultIndex={item.defaultIndex ?? +this.defaultIndex}
swipeDuration={this.swipeDuration}
visibleItemCount={this.visibleItemCount}
initialOptions={item.values}
diff --git a/src/progress/index.js b/src/progress/index.js
index f12ca19a9..9d90b94ba 100644
--- a/src/progress/index.js
+++ b/src/progress/index.js
@@ -1,4 +1,4 @@
-import { createNamespace, isDef, addUnit } from '../utils';
+import { createNamespace, addUnit } from '../utils';
const [createComponent, bem] = createNamespace('progress');
@@ -49,7 +49,7 @@ export default createComponent({
render() {
const { pivotText, percentage } = this;
- const text = isDef(pivotText) ? pivotText : percentage + '%';
+ const text = pivotText ?? percentage + '%';
const showPivot = this.showPivot && text;
const background = this.inactive ? '#cacaca' : this.color;
diff --git a/src/share-sheet/index.js b/src/share-sheet/index.js
index 744ca0ae7..39335f436 100644
--- a/src/share-sheet/index.js
+++ b/src/share-sheet/index.js
@@ -1,5 +1,5 @@
// Utils
-import { createNamespace, isDef } from '../utils';
+import { createNamespace } from '../utils';
// Mixins
import { popupMixinProps } from '../mixins/popup';
@@ -112,7 +112,7 @@ export default createComponent({
},
genCancelText() {
- const cancelText = isDef(this.cancelText) ? this.cancelText : t('cancel');
+ const cancelText = this.cancelText ?? t('cancel');
if (cancelText) {
return (
diff --git a/src/sidebar-item/index.js b/src/sidebar-item/index.js
index 41a64767b..54d587f1d 100644
--- a/src/sidebar-item/index.js
+++ b/src/sidebar-item/index.js
@@ -1,4 +1,4 @@
-import { createNamespace, isDef } from '../utils';
+import { createNamespace } from '../utils';
import { ChildrenMixin } from '../mixins/relation';
import { route, routeProps } from '../utils/router';
import Info from '../info';
@@ -46,7 +46,7 @@ export default createComponent({
{this.title}
diff --git a/src/sku/Sku.js b/src/sku/Sku.js
index 230c26191..919ab40b1 100644
--- a/src/sku/Sku.js
+++ b/src/sku/Sku.js
@@ -10,7 +10,7 @@ import SkuRowPropItem from './components/SkuRowPropItem';
import SkuStepper from './components/SkuStepper';
import SkuMessages from './components/SkuMessages';
import SkuActions from './components/SkuActions';
-import { createNamespace, isDef } from '../utils';
+import { createNamespace } from '../utils';
import {
isAllSelected,
isSkuChoosable,
@@ -361,7 +361,7 @@ export default createComponent({
resetStepper() {
const { skuStepper } = this.$refs;
const { selectedNum } = this.initialSku;
- const num = isDef(selectedNum) ? selectedNum : this.startSaleNum;
+ const num = selectedNum ?? this.startSaleNum;
// 用来缓存不合法的情况
this.stepperError = null;
diff --git a/src/stepper/index.js b/src/stepper/index.js
index ecf0b0942..b31a85177 100644
--- a/src/stepper/index.js
+++ b/src/stepper/index.js
@@ -72,7 +72,7 @@ export default createComponent({
},
data() {
- const defaultValue = isDef(this.value) ? this.value : this.defaultValue;
+ const defaultValue = this.value ?? this.defaultValue;
const value = this.format(defaultValue);
if (!equal(value, this.value)) {
diff --git a/src/tab/index.js b/src/tab/index.js
index 75489232e..892f798c2 100644
--- a/src/tab/index.js
+++ b/src/tab/index.js
@@ -1,4 +1,4 @@
-import { isDef, createNamespace } from '../utils';
+import { createNamespace } from '../utils';
import { ChildrenMixin } from '../mixins/relation';
import { routeProps } from '../utils/router';
@@ -26,7 +26,7 @@ export default createComponent({
computed: {
computedName() {
- return isDef(this.name) ? this.name : this.index;
+ return this.name ?? this.index;
},
isActive() {
diff --git a/src/tabbar-item/index.js b/src/tabbar-item/index.js
index 80b273532..309663f44 100644
--- a/src/tabbar-item/index.js
+++ b/src/tabbar-item/index.js
@@ -71,10 +71,7 @@ export default createComponent({
{this.genIcon(active)}
-
+
{this.slots('default', { active })}
diff --git a/src/tabs/index.js b/src/tabs/index.js
index ddafe2556..86ea14c26 100644
--- a/src/tabs/index.js
+++ b/src/tabs/index.js
@@ -359,7 +359,7 @@ export default createComponent({
refInFor
type={type}
dot={item.dot}
- info={isDef(item.badge) ? item.badge : item.info}
+ info={item.badge ?? item.info}
title={item.title}
color={this.color}
style={item.titleStyle}
diff --git a/src/tree-select/index.tsx b/src/tree-select/index.tsx
index 0ca699f6d..6c1685a67 100644
--- a/src/tree-select/index.tsx
+++ b/src/tree-select/index.tsx
@@ -1,5 +1,5 @@
// Utils
-import { createNamespace, addUnit, isDef } from '../utils';
+import { createNamespace, addUnit } from '../utils';
import { emit, inherit } from '../utils/functional';
// Components
@@ -65,7 +65,7 @@ function TreeSelect(
const Navs = items.map((item) => (
{
- result = isDef(result[key]) ? result[key] : '';
+ result = result[key] ?? '';
});
return result;