b2nil / taro-ui-vue3

采用 Vue 3.0 重写的 Taro UI 组件库
https://b2nil.github.io/taro-ui-vue3/
MIT License
160 stars 51 forks source link

Card 展示页面返回时报错 #2

Closed b2nil closed 4 years ago

b2nil commented 4 years ago

AtCard 的自定义图标展示中:<at-card :renderIcon="renderIcon()">...</at-card>, renderIcon 属性绑定的数据是一个匿名函数: const renderIcon = () => h(AtIcon, {...}), 导致页面返回销毁组件时报错:

VM457:1 TypeError: Cannot read property 'bum' of null
    at unmountComponent (runtime-core.esm-bundler.js:4632)
    at unmount (runtime-core.esm-bundler.js:4549)
    at unmountChildren (runtime-core.esm-bundler.js:4681)
    at unmount (runtime-core.esm-bundler.js:4564)
    at unmountComponent (runtime-core.esm-bundler.js:4646)
    at unmount (runtime-core.esm-bundler.js:4549)
    at unmountChildren (runtime-core.esm-bundler.js:4681)
    at unmount (runtime-core.esm-bundler.js:4567)
    at patchKeyedChildren (runtime-core.esm-bundler.js:4370)
    at patchChildren (runtime-core.esm-bundler.js:4261)

renderIcon 属性只需绑定一个 AtIcon VNode 节点,正确的写法如下:

<at-card :renderIcon="renderIcon">...</at-card>
// data
const renderIcon = h(AtIcon, {...})