찾다
위챗 애플릿미니 프로그램 개발미니 프로그램 개발 시 목록의 풀업 로딩 및 풀다운 새로 고침 효과 구현에 대한 튜토리얼

위챗 미니 프로그램은 9월 21일 이후 가장 핫한 용어라고 할 수 있다. 일단 등장하고 나면 정말 모든 개발자들이 충격에 빠졌다. 물론 많은 앱 개발자들은 위챗 미니 프로그램의 등장이 안드로이드 개발자로서 모바일 앱을 전복시키지 않을까 걱정하고 있다. 나는 모바일 프로그래머가 일자리를 잃을 것이라고는 생각하지 않습니다. 설사 그런 일이 있더라도 이를 달성하려면 1~2년의 전환과 연마가 필요할 것입니다.
WeChat 미니 프로그램이 오늘날의 모바일 개발 환경을 뒤바꿀 수 있더라도 우리는 받아들이고 배우는 긍정적인 태도를 가져야 합니다. 우리는 새로운 기술을 거부하지 않으므로 먼저 WeChat 애플릿 개발 도구를 빠르게 구축하는 것보다 행동하는 것이 좋습니다. 그러면 목록의 풀업 로딩 및 풀다운 새로 고침 구현(집계 데이터 플랫폼을 통해 WeChat 뉴스 가져오기)을 시작해 보겠습니다.
1. 여러 컴포넌트 소개
1.1 스크롤뷰 컴포넌트
미니 프로그램 개발 시 목록의 풀업 로딩 및 풀다운 새로 고침 효과 구현에 대한 튜토리얼

참고: 세로 스크롤을 사용할 때는 고정 높이를 제공하고 WXSS를 통해 높이를 설정해야 합니다.
1.2 이미지 구성 요소

Picture: 2.jpg

미니 프로그램 개발 시 목록의 풀업 로딩 및 풀다운 새로 고침 효과 구현에 대한 튜토리얼


참고: 모드에는 12개의 모드가 있으며 그 중 3개는 확대/축소 모드이고 9개는 자르기 모드입니다.
1.3 아이콘 컴포넌트

사진: 3.jpg

미니 프로그램 개발 시 목록의 풀업 로딩 및 풀다운 새로 고침 효과 구현에 대한 튜토리얼




iconType: [ ‘success', ‘info', ‘warn', ‘waiting', ‘safe_success', ‘safe_warn', ‘success_circle', ‘success_no_circle', ‘waiting_circle', ‘circle', ‘download', 
‘info_circle', ‘cancel', ‘search', ‘clear' 
]

2. 목록 풀업 로딩 및 풀다운 새로 고침 구현
2.1 렌더링을 살펴보겠습니다.

그림: 4.gif

미니 프로그램 개발 시 목록의 풀업 로딩 및 풀다운 새로 고침 효과 구현에 대한 튜토리얼


2.2 논리는 매우 간단합니다. 코드로 이동하세요.
2.2.1detail.wxml 레이아웃 파일
<loading hidden="pw_hidden" bindchange="loadingChange">
 加载中... </loading> 
 <scroll-view scroll-y="true" style="height: 100%;" bindscrolltolower="loadMore" bindscrolltoupper="refesh"> <view wx:if="pw_hasRefesh" style="display: flex;flex-direction: row;align-items: center;align-self: center;justify-content: center;"> <icon type="waiting" size="45"/><text>刷新中...</text></view> <view wx:else style="display:none" ><text></text></view> <view class="lll" wx:for="pw_list" wx:for-item="item" bindtap="bindViewTap" data-title="pw_item.title" > <image style=" width: 50px;height: 50px;margin: 20rpx;" src="pw_item.firstImg" ></image> <view class="eee" > 
 <view style="margin:5px;font-size:8px"> 标题:pw_item.title</view> <view style="margin:5px;color:red;font-size:6px"> 来源:pw_item.source</view> </view></view><view class="tips1"> <view wx:if="pw_hasMore" style="display: flex;flex-direction: row;align-items: center;align-self: center;justify-content: center;"> <icon type="waiting" size="45"/><text>玩命的加载中...</text></view> <view wx:else><text>没有更多内容了</text></view> </view> </scroll-view>

2.2.1detail.js 논리 코드 파일
var network_util = require(&#39;../../utils/network_util.js&#39;);var json_util = require(&#39;../../utils/json_util.js&#39;);Page({
 data:{ // text:"这是一个页面"
 list:[],
 dd:&#39;&#39;,
 hidden:false,
 page: 1,
 size: 20,
 hasMore:true,
 hasRefesh:false },
 onLoad:function(options){ var that = this; var url = &#39;http://v.juhe.cn/weixin/query?key=f16af393a63364b729fd81ed9fdd4b7d&pno=1&ps=10&#39;;
 network_util._get(url, function(res){
 that.setData({
 list:res.data.result.list,
 hidden: true, }); },function(res){
 console.log(res); }); },
 onReady:function(){ // 页面渲染完成 },
 onShow:function(){ // 页面显示 },
 onHide:function(){ // 页面隐藏  },
 onUnload:function(){ // 页面关闭 }, //点击事件处理
 bindViewTap: function(e) {
 console.log(e.currentTarget.dataset.title); }, //加载更多
 loadMore: function(e) { var that = this;
 that.setData({
 hasRefesh:true,}); if (!this.data.hasMore) return var url = &#39;http://v.juhe.cn/weixin/query?key=f16af393a63364b729fd81ed9fdd4b7d&pno=&#39;+(++that.data.page)+&#39;&ps=10&#39;;
 network_util._get(url, function(res){
 that.setData({
 list: that.data.list.concat(res.data.result.list),
 hidden: true,
 hasRefesh:false, }); },function(res){
 console.log(res); })},//刷新处理refesh: function(e) { var that = this;
 that.setData({
 hasRefesh:true, }); var url = &#39;http://v.juhe.cn/weixin/query?key=f16af393a63364b729fd81ed9fdd4b7d&pno=1&ps=10&#39;;
 network_util._get(url, function(res){
 that.setData({
 list:res.data.result.list,
 hidden: true,
 page:1,
 hasRefesh:false, }); },function(res){
 console.log(res); })},})

최종 효과:

사진 :5.jpg

미니 프로그램 개발 시 목록의 풀업 로딩 및 풀다운 새로 고침 효과 구현에 대한 튜토리얼

위 내용은 미니 프로그램 개발 시 목록의 풀업 로딩 및 풀다운 새로 고침 효과 구현에 대한 튜토리얼의 상세 내용입니다. 자세한 내용은 PHP 중국어 웹사이트의 기타 관련 기사를 참조하세요!

성명
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.

핫 AI 도구

Undresser.AI Undress

Undresser.AI Undress

사실적인 누드 사진을 만들기 위한 AI 기반 앱

AI Clothes Remover

AI Clothes Remover

사진에서 옷을 제거하는 온라인 AI 도구입니다.

Undress AI Tool

Undress AI Tool

무료로 이미지를 벗다

Clothoff.io

Clothoff.io

AI 옷 제거제

Video Face Swap

Video Face Swap

완전히 무료인 AI 얼굴 교환 도구를 사용하여 모든 비디오의 얼굴을 쉽게 바꾸세요!

뜨거운 도구

에디트플러스 중국어 크랙 버전

에디트플러스 중국어 크랙 버전

작은 크기, 구문 강조, 코드 프롬프트 기능을 지원하지 않음

PhpStorm 맥 버전

PhpStorm 맥 버전

최신(2018.2.1) 전문 PHP 통합 개발 도구

SublimeText3 Linux 새 버전

SublimeText3 Linux 새 버전

SublimeText3 Linux 최신 버전

WebStorm Mac 버전

WebStorm Mac 버전

유용한 JavaScript 개발 도구

ZendStudio 13.5.1 맥

ZendStudio 13.5.1 맥

강력한 PHP 통합 개발 환경