Tag Archives: uview u-sticky Error

[Solved] uview u-sticky Error: Cannot read property ‘bottom‘ of null

The causes are:

The component u-sticky and the bottom navigation bar tabbar conflict when switching pages, the sticky component creates an Observer listener, and when the page is switched and not destroyed, it causes the component to remain listening, so the error Cannot read property ‘bottom’ of null appears. So we need to disconnect the Observer listener manually to solve this error problem

Source code:

<u-sticky offset-top="200" >

</u-sticky>

 

Modified:

<template>
	
		<u-sticky offset-top="200" :enable="enable">
				
		</u-sticky>
</template>

<script>
	export default {
		data() {
			return {
				// @property {Boolean} enable Whether to open the ceiling function(default is true)
				enable:true
			}
		},
		// Turn on or off listeners in the corresponding show and hide page lifecycle
		onShow() {
			this.enable= true
		},
		onHide() {
			this.enable= false
		}

	}
</script>