diff --git a/packages/vant/src/empty/Empty.tsx b/packages/vant/src/empty/Empty.tsx
index 8df0beff1..e61fb69df 100644
--- a/packages/vant/src/empty/Empty.tsx
+++ b/packages/vant/src/empty/Empty.tsx
@@ -5,11 +5,21 @@ import {
makeStringProp,
createNamespace,
} from '../utils';
-import { Network } from './Network';
+import {
+ renderError,
+ renderSearch,
+ renderNetwork,
+ renderMaterial,
+} from './Images';
const [name, bem] = createNamespace('empty');
-const PRESET_IMAGES = ['error', 'search', 'default'];
+const PRESET_IMAGES: Record JSX.Element> = {
+ error: renderError,
+ search: renderSearch,
+ network: renderNetwork,
+ default: renderMaterial,
+};
const emptyProps = {
image: makeStringProp('default'),
@@ -29,18 +39,7 @@ export default defineComponent({
if (slots.image) {
return slots.image();
}
-
- let { image } = props;
-
- if (image === 'network') {
- return Network;
- }
-
- if (PRESET_IMAGES.includes(image)) {
- image = `https://img.yzcdn.cn/vant/empty-image-${image}.png`;
- }
-
- return
;
+ return PRESET_IMAGES[props.image]?.() ||
;
};
const renderDescription = () => {
diff --git a/packages/vant/src/empty/Images.tsx b/packages/vant/src/empty/Images.tsx
new file mode 100644
index 000000000..8b360e060
--- /dev/null
+++ b/packages/vant/src/empty/Images.tsx
@@ -0,0 +1,203 @@
+const getId = (num: number | string) => `van-empty-${num}`;
+const useId = (num: number | string) => `url(#${getId(num)})`;
+
+const renderStop = (color: string, offset: number, opacity?: number) => (
+
+);
+
+const renderStops = (fromColor: string, toColor: string) => [
+ renderStop(fromColor, 0),
+ renderStop(toColor, 100),
+];
+
+const renderShadow = (id: string) => [
+
+
+ {renderStop('#EBEDF0', 0)}
+ {renderStop('#F2F3F5', 100, 0.3)}
+
+ ,
+ ,
+];
+
+const renderBuilding = () => [
+
+
+ {renderStop('#FFF', 0, 0.5)}
+ {renderStop('#F2F3F5', 100)}
+
+ ,
+
+
+
+ ,
+];
+
+const renderCloud = () => [
+
+
+ {renderStop('#F2F3F5', 0, 0.3)}
+ {renderStop('#F2F3F5', 100)}
+
+ ,
+
+
+
+ ,
+];
+
+export const renderNetwork = () => (
+
+);
+
+export const renderMaterial = () => (
+
+);
+
+export const renderError = () => (
+
+);
+
+export const renderSearch = () => (
+
+);
diff --git a/packages/vant/src/empty/Network.tsx b/packages/vant/src/empty/Network.tsx
deleted file mode 100644
index 8bb2e356e..000000000
--- a/packages/vant/src/empty/Network.tsx
+++ /dev/null
@@ -1,63 +0,0 @@
-const prefix = 'van-empty-network-';
-const renderStop = (color: string, offset: number, opacity?: number) => (
-
-);
-
-export const Network = (
-
-);
diff --git a/packages/vant/src/empty/test/__snapshots__/demo.spec.ts.snap b/packages/vant/src/empty/test/__snapshots__/demo.spec.ts.snap
index 7e1cd50f3..06f462c3e 100644
--- a/packages/vant/src/empty/test/__snapshots__/demo.spec.ts.snap
+++ b/packages/vant/src/empty/test/__snapshots__/demo.spec.ts.snap
@@ -4,7 +4,169 @@ exports[`should render demo and match snapshot 1`] = `
-

+
Description
@@ -67,7 +229,111 @@ exports[`should render demo and match snapshot 1`] = `
>
-

+
Description
@@ -98,7 +364,169 @@ exports[`should render demo and match snapshot 1`] = `
-

+
Description
@@ -120,7 +548,169 @@ exports[`should render demo and match snapshot 1`] = `
-

+
Description
diff --git a/packages/vant/src/empty/test/__snapshots__/index.spec.ts.snap b/packages/vant/src/empty/test/__snapshots__/index.spec.ts.snap
index b60cf694c..f0170d931 100644
--- a/packages/vant/src/empty/test/__snapshots__/index.spec.ts.snap
+++ b/packages/vant/src/empty/test/__snapshots__/index.spec.ts.snap
@@ -3,7 +3,169 @@
exports[`should render bottom slot correctly 1`] = `
-

+
Custom bottom
@@ -14,7 +176,169 @@ exports[`should render bottom slot correctly 1`] = `
exports[`should render description slot correctly 1`] = `
-

+
Custom description
@@ -35,7 +359,7 @@ exports[`should render svg when image is network 1`] = `