npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

miniprogram-infinitescroll

v0.0.30

Published

小程序composition 上拉加载

Downloads

12

Readme

miniprogram-infinitescroll

NPM version NPM downloads

小程序 mobx composition 下拉加载

Usage

TODO

Options

TODO

Development

LICENSE

MIT

<view style="margin-bottom: 50rpx;display: flex;">
  <!-- id名对应表单字段名 -->
  <input
    id="keywords"
    bindinput="change"
    value="{{values.keywords}}"
    style="border: solid 1px ;height:80rpx;flex: 6;"
  />
  <button bindtap="search" style="flex: 1;">搜索</button>
  <button bindtap="reset" style="flex:1;">重置</button>
</view>
<view wx:if="{{loading}}"> 载入中 </view>
<view wx:elif="{{error}}"> 载入出错 </view>
<view wx:else>
  <scroll-view
    bindscrolltolower="bindscrolltolower"
    style="max-height: 1000rpx;"
    lower-threshold="{{200}}"
    scroll-y
  >
    <view>
      <view style="margin-bottom: 50rpx;" wx:for="{{data.list}}">
        <view style="margin-bottom: 20rpx;">
          <text>{{item.name}}</text>
        </view>
      </view>
    </view>
  </scroll-view>
  <view wx:if="{{noMore}}">
    {{ data.list.length ? '共'+data.list.length+'条,没有更多了' :
    '没有相关数据'}}
  </view>
  <view wx:elif="{{errorMore}}"> 加载更多出错 </view>
  <view wx:elif="{{loadingMore}}"> 加载更多中 </view>
  <view style="float: right;">
    <button loading="{{loadMore}}" bindtap="loadMore">手动点击加载更多</button>
  </view>
</view>
//搜索下拉列表
import { useForm, useSearchInfiniteScroll } from 'miniprogram-infinitescroll';
import { compositionApi } from 'miniprogram-composition';

const getData = ({ current, pageSize }, formData) => {
  return new Promise((resolve, reject) => {
    wx.request({
      url: 'http://cloud-music.pl-fe.cn/search',
      data: {
        limit: pageSize,
        offset: (current - 1) * pageSize,
        ...formData,
      },
      success: (res) => resolve(res.data),
      fail: reject,
    });
  });
};

Component({
  behaviors: [compositionApi],
  setup() {
    const form = useForm({
      keywords: '红颜如霜',
    });
    const { values, change, setValues, reset: resetValues } = form;
    const {
      loadMore,
      loadMoreAsync, //返回promise的加载更多
      bindscrolltolower,
      data,
      loading,
      loadingMore,
      error,
      errorMore,
      noMore,
      search,
      searchAysnc, //返回promise的搜索
      reset,
    } = useSearchInfiniteScroll(
      async ({ current, pageSize }, formData) => {
        const res = await getData({ current, pageSize }, formData);
        return {
          list: res.result.songs,
          total: res.result.songCount,
        };
      },
      {
        form,
        defaultPageSize: 20,
      },
    );
    return {
      error, //出错
      errorMore, //加载更多出错
      values, //表单值
      change, //表单变化事件
      loadMore, //载入更多
      search, //搜索
      reset, //重置
      noMore, //是否没有更多数据了
      data, //列表数据
      loading, //加载中
      loadingMore, //加载更多中
      bindscrolltolower, //下拉事件
    };
  },
});