slider销毁的时候报错
来源:2-3 项目基础代码编写
慕哥5572714
2022-04-29
切换模块的时候报错: slider.value.destory is not a function,是什么原因?
下面是代码
import BScroll from "@better-scroll/core";
import Slide from "@better-scroll/slide";
import { onMounted, onUnmounted, ref } from 'vue';
BScroll.use(Slide)
export default function useSlider(wrapperRef) {
const slider = ref(null)
const currentPageIndex = ref(0)
onMounted(() => {
const sliderVal = slider.value = new BScroll(wrapperRef.value, {
click: true,
scrollX: true,
scrollY: false,
momentum: false,
bounce: false,
probeType: 2,
slide: true,
})
sliderVal.on('slideWillChange', page => {
currentPageIndex.value = page.pageX
})
})
onUnmounted(() => {
slider.value.destory()
})
return {
slider,
currentPageIndex
}
}
写回答
1回答
-
ustbhuangyi
2022-05-03
代码写错了吧,仔细检查一下
012022-05-24
相似问题
UnMountend生命周期
回答 1
关于销毁sliderVal的问题
回答 1