1.uniapp 从列表进入详情页,再返回列表页时回到上次的浏览位置
<script>
export default {data() {return {listData: [],scrollTop: 0,};},onShow() {this.getShopData();},onPageScroll: function (e) {this.scrollTop = e.scrollTop;},onBackPress(options) {if (options.from === 'backbutton') {uni.removeStorage({key: 'newsTop'});uni.navigateBack();return true;}},methods: {getShopData() {getShopList().then((res) => {this.listData = res.data.list.data;uni.getStorage({key: 'newsTop',success: (res) => {console.log(res);if (res.data) {uni.pageScrollTo({scrollTop: res.data,duration: 0,});}},});}).finally(() => {});},editShop(storeId = '') {uni.setStorage({key: 'newsTop',data: this.scrollTop,});uni.navigateTo({url: '/pages/edit/shop/shop?store_id=' + storeId,});},},
};
</script>