Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to fix the Mini Program navigation after scrolling to the head?

2025-04-02 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly explains "how to fix Mini Program navigation after scrolling to the head". The content in the article is simple and clear, and it is easy to learn and understand. let's study and learn how to fix Mini Program navigation after scrolling to the head.

The previous code is more important here.

{{navItem.text}} the overall layout of the front segment should use scroll-view

.positionfixed {position: fixed;left: 0 * top: 0;} data configuration information is promising

Data: {adData: ['http://pic.qiantucdn.com/58pic/17/70/72/02U58PICKVg_1024.jpg',' http://pic2.ooopic.com/12/09/64/46bOOOPICf5_1024.jpg'],navData: [{text: 'home'}, {text: 'health'}, {text: 'emotion'}, {text: 'workplace'}, {text: 'parenting'}, {text: 'dispute'} {text: 'green onions'}, {text: 'class'}, {text: 'class'}], currentNavTab: 0scrollTop:', / / the distance to slide navFixed: false, / / whether the navigation is fixed onLoad method to obtain width and height

Wx.getSystemInfo ({success: (res) = > {this.setData ({pixelRatio: res.pixelRatio,windowHeight: res.windowHeight,windowWidth: res.windowWidth})},}) js main event

/ / Navigation Click switchNav (event) {var cur = event.currentTarget.dataset.current;// the width of each tab option accounts for 1/5var singleNavWidth = this.data.windowWidth / 5 alternate tab tab option center this.setData ({navScrollLeft: (cur-2) * singleNavWidth}) if (this.data.currentNavTab = = cur) {return false } else {this.setData ({currentNavTab: cur})}}, / / listen for sliding layoutScroll: function (e) {this.data.scrollTop = this.data.scrollTop * 1 + e.detail.deltaY * 1 console.log (this.data.scrollTop) console.log (this.data.navFixed) if (this.data.scrollTop)

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report