Skip to content

Commit 711f9cc

Browse files
authored
fix(lazyload): lazy-image h is not a function (#11230)
in vue 3.x h is not function. this.$slots.default is a function. [vue 3.x refs render-function-api-change](https://github.com/vuejs/rfcs/blob/master/active-rfcs/0008-render-function-api-change.md) [vue 3.x docs h](https://cn.vuejs.org/api/render-function.html#h) - reappear - test ```vue // vant/packages/vant/src/lazyload/demo/index.vue <script lang="ts"> import Lazyload from '..'; if (window.app) { window.app.use(Lazyload, { lazyComponent: true, lazyImage: true }); } </script> <template> <demo-block :title="t('basicUsage')"> <lazy-image v-for="img in imageList" :key="img" :src="img"> </lazy-image> </demo-block> </teamplate> ```
1 parent 97d2bad commit 711f9cc

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

packages/vant/src/lazyload/vue-lazyload/lazy-image.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import { useRect } from '@vant/use';
77
import { loadImageAsync } from './util';
88
import { noop } from '../../utils';
9+
import { h } from 'vue';
910

1011
export default (lazyManager) => ({
1112
props: {
@@ -15,15 +16,13 @@ export default (lazyManager) => ({
1516
default: 'img',
1617
},
1718
},
18-
render(h) {
19+
render() {
1920
return h(
2021
this.tag,
2122
{
22-
attrs: {
23-
src: this.renderSrc,
24-
},
23+
src: this.renderSrc,
2524
},
26-
this.$slots.default
25+
this.$slots.default?.()
2726
);
2827
},
2928
data() {

0 commit comments

Comments
 (0)