uniapp operation scroll-view switch scroll bar does not return to the top

 Requirement: Return the scroll bar of scroll-view to the top every time you switch categories

        After we bind the scroll-top attribute to the scroll-view, we assign a value to the scroll through the event processing function, so that each switch can return to the top

        But it doesn't take effect, because every assignment to the same value doesn't take effect!

<template>
    <scroll-view 
        class="right-scroll-view" 
        :scroll-top="scrollTop" 
        scroll-y 
        :style="{height:wh+'px'}">
    </scroll-view>
<template>

<script>
export default {
    data(){
        // 距离参数
        scrollTop:0
    },
    // 切换页面事件
	activeChanged(i) {
		this.scrollTop = 0
	},
}
</script>

Correct spelling:

        This problem can be solved by assigning different data each time the value is assigned.

activeChanged(i) {
	this.scrollTop = this.scrollTop === 0 ? 1 : 0
},

Guess you like

Origin blog.csdn.net/Kerwin__li/article/details/128671774