From f071e48be2329b00499737779815074a2baa2dba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8B=A5=E5=B7=9D?= Date: Tue, 8 Nov 2022 10:16:20 +0800 Subject: [PATCH] fix(lazyload): lazy-image h is not a function (#11229) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 文档 h 渲染函数](https://cn.vuejs.org/api/render-function.html#h) --- packages/vant/src/lazyload/vue-lazyload/lazy-image.js | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/packages/vant/src/lazyload/vue-lazyload/lazy-image.js b/packages/vant/src/lazyload/vue-lazyload/lazy-image.js index 40d7045ae..8d6f17ea9 100644 --- a/packages/vant/src/lazyload/vue-lazyload/lazy-image.js +++ b/packages/vant/src/lazyload/vue-lazyload/lazy-image.js @@ -6,6 +6,7 @@ import { useRect } from '@vant/use'; import { loadImageAsync } from './util'; import { noop } from '../../utils'; +import { h } from 'vue'; export default (lazyManager) => ({ props: { @@ -15,15 +16,13 @@ export default (lazyManager) => ({ default: 'img', }, }, - render(h) { + render() { return h( this.tag, { - attrs: { - src: this.renderSrc, - }, + src: this.renderSrc, }, - this.$slots.default + this.$slots.default?.() ); }, data() {