import { onLoad, onUnload, onPullDownRefresh, onResize, onShow, onReachBottom } from '@dcloudio/uni-app'
import { ref } from "vue"
export const useListLifeCycle = function() {
const showType = ref("card")
//事件无法触发
onResize(e1 => {
console.log("onResize")
showType.value = e1.deviceOrientation === 'portrait' ? 'card' : 'table';
console.log("showType", showType.value)
})
//事件正常触发
onShow(() => {
const sysInfo = uni.getSystemInfoSync();
showType.value = sysInfo.screenWidth < sysInfo.screenHeight ? 'card' : 'table';
console.log("onshow", showType.value)
})
//事件正常触发
onReachBottom(() => {
console.log(" on reach bottom")
})
return { showType }
}
0 个回复