Skip to content
This repository was archived by the owner on Dec 6, 2021. It is now read-only.

Commit e3c3dc4

Browse files
committed
fix(toast): ReferenceError: Cannot access 'state' before initialization
1 parent cb415ea commit e3c3dc4

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/components/toast/index.ts

+7-3
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,19 @@ const AtToast = defineComponent({
2121
duration: { type: Number, default: 3000 },
2222
hasMask: Boolean,
2323
onClick: Function as PropType<AtToastProps['onClick']>,
24-
onClose: Function as PropType<AtToastProps['onClick']>,
24+
onClose: Function as PropType<AtToastProps['onClose']>,
2525
},
2626

27-
setup(props: AtToastProps, { attrs, slots }) {
27+
setup(props: AtToastProps, { attrs }) {
2828
const state = reactive({
29-
_timer: props.isOpened ? makeTimer(props.duration || 0) : null as NodeJS.Timeout | null,
29+
_timer: null as NodeJS.Timeout | null,
3030
_isOpened: props.isOpened
3131
})
3232

33+
if (props.isOpened) {
34+
makeTimer(props.duration || 0)
35+
}
36+
3337
const realImg = computed(() => (props.image || statusImg[props.status!] || null))
3438
const isRenderIcon = computed(() => !!(props.icon && !(props.image || statusImg[props.status!])))
3539

0 commit comments

Comments
 (0)