WeChatには、リスト内の文字をクリックして、対応する位置にジャンプする機能はありますか? この記事では、主にWeChatアプレットの友人リスト文字リストの開発に関する関連情報を紹介し、対応する位置にジャンプします。この記事が、この機能を必要とする友人の皆様の参考になれば幸いです。
WeChat アプレットの開発: 友達リストの文字リストが対応する位置にジャンプします
前書き:
アプレットで、WeChat 友達リストの右側にある文字リストをクリックするとジャンプする効果を実現します。対応する位置。コア部分は非常に簡単なデモを作成したので、問題が発生した場合はグループに参加して質問してください。
中心的な技術ポイント:
1. ミニ プログラムのスクロール ビュー コンポーネントのスクロールイントゥ 属性とスクロール ウィズ アニメーション属性。
2. ミニプログラムのタッチイベントの応用。
3. Jsタイマーの応用。
ページのコード:
index.wxml
class="container" scroll-y> class="info" id="info" scroll-with-animation scroll-y scroll-top="200" scroll-into-view="{{toView}}" style="height:{{height}}px;"> class="iitem" id="{{item.id}}" wx:for="{{info_list}}" wx:key="1"> {{item.id}} . {{item.desc}} class="letter {{active == true ? 'active': ''}}" bindtouchstart='start' bindtouchmove='move' bindtouchend='end'> class="litem" bindtap='down' data-index="999">☆ class="litem" wx:for="{{letter_list}}" bindtap='down' wx:for-index="index" wx:key="2" data-index="{{index}}" style="height: {{letter_height}}px;">{{item}} class="tips" hidden="{{hide}}">{{curView}}
js コード:
index.js
//index.js //获取应用实例 const app = getApp() Page({ data: { letter_list: [], info_list: [], hide: true, active: false, toView: 'A', curView: 'A', letter_height: 18 }, onLoad: function () { this.active = false; this.timer = null; var letter_list = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z']; var info_list = []; for (var i = 0; i < 26; i++) { var obj = {}; obj.id = letter_list; obj.desc = '这是一个用于测试的DEMO。1.目标是用于实现微信好友列表的点击首字母跳转到对应好友位置。2.目标是用于实现微信好友列表的点击首字母跳转到对应好友位置'; info_list.push(obj); } this.setData({ height: app.globalData.height, info_list: info_list, letter_list: letter_list, sHeight: 100 * 26 + 25 }); }, start: function (e) { this.setData({ active: true, hide: false }) }, end: function (e) { if (this.timer) { clearTimeout(this.timer); this.timer = null; } var moveY = e.changedTouches["0"].clientY - 18, that = this; var curIndex = parseInt(moveY / 18); var view = this.data.letter_list[curIndex]; this.setData({ toView: view, active: false }); if (!this.timer) { this.timer = setTimeout(function () { that.setData({ hide: true }) that.timer = null; }, 1000); } }, move: function (e) { var moveY = e.changedTouches["0"].clientY - 18; var curIndex = parseInt(moveY / 18); var view = this.data.letter_list[curIndex]; this.setData({ curView: view }) }, down: function (e) { if (this.timer) { clearTimeout(this.timer); this.timer = null; } var index = e.currentTarget.dataset.index, that = this; if (index != 999) { var view = this.data.letter_list[index]; this.setData({ toView: view, curView: view }) } else { this.setData({ toView: 'A', curView: '☆' }) } if (!this.timer) { this.timer = setTimeout(function () { that.setData({ hide: true }); that.timer = null; }, 1000); } } })
スタイル部分
index.wxss
/**index.wxss**/ text { font-weight: bold } .letter { font-size: 12px; width: 24px; height: 100%; position: fixed; right: 0; top: 0; z-index: +999; } .litem { width: 24px; height: 18px; line-height: 18px; text-align: center; } .info { font-size: 12px; text-align: justify; overflow: hidden; } .active { background: rgba(0, 0, 0, 0.2); } .iitem { padding: 10rpx 10rpx; margin-bottom: 10rpx; border-radius: 8rpx; background: rgba(222,222,222,0.2); box-sizing: border-box; } .tips { width: 40px; height: 40px; background: rgba(0,0,0,0.4); font-size: 20px; text-align: center; line-height: 40px; color: #fff; position: fixed; left: 50%; top: 50%; margin: -20px; z-index: +999; border-radius: 10rpx;
関連するおすすめ:
WeChaアプレットのスクロールビューコンテナの使い方実装するには
Thinkphp5 WeChatアプレットのユーザー情報インターフェースを取得する方法
以上がWeChat友達リスト内の文字をクリックすると、対応する位置にジャンプすることを実現する方法の詳細内容です。詳細については、PHP 中国語 Web サイトの他の関連記事を参照してください。

ホットAIツール

Undresser.AI Undress
リアルなヌード写真を作成する AI 搭載アプリ

AI Clothes Remover
写真から衣服を削除するオンライン AI ツール。

Undress AI Tool
脱衣画像を無料で

Clothoff.io
AI衣類リムーバー

AI Hentai Generator
AIヘンタイを無料で生成します。

人気の記事

ホットツール

AtomエディタMac版ダウンロード
最も人気のあるオープンソースエディター

SAP NetWeaver Server Adapter for Eclipse
Eclipse を SAP NetWeaver アプリケーション サーバーと統合します。

PhpStorm Mac バージョン
最新(2018.2.1)のプロフェッショナル向けPHP統合開発ツール

ドリームウィーバー CS6
ビジュアル Web 開発ツール

mPDF
mPDF は、UTF-8 でエンコードされた HTML から PDF ファイルを生成できる PHP ライブラリです。オリジナルの作者である Ian Back は、Web サイトから「オンザフライ」で PDF ファイルを出力し、さまざまな言語を処理するために mPDF を作成しました。 HTML2FPDF などのオリジナルのスクリプトよりも遅く、Unicode フォントを使用すると生成されるファイルが大きくなりますが、CSS スタイルなどをサポートし、多くの機能強化が施されています。 RTL (アラビア語とヘブライ語) や CJK (中国語、日本語、韓国語) を含むほぼすべての言語をサポートします。ネストされたブロックレベル要素 (P、DIV など) をサポートします。
