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

ant-mini-scratch-card

v1.0.8

Published

支付宝小程序刮刮卡组件

Downloads

33

Readme

小程序刮刮卡组件

使用说明

安装组件

yarn add @alipay/ant-mini-scratchCard

使用示例

json

{
  "defaultTitle": "刮刮卡小程序组件",
  "allowsBounceVertical": "NO",
  "usingComponents": {
    "scratch": "@alipay/ant-mini-scratchCard/es/scratch/index"
  }
}

xaml

<view>
  <scratch
    tipText="刮刮我,有惊喜~"
    tipColor="#902d02"
    coverColor="#ffae8a"
    ctxLogoUrl="https://gw.alipayobjects.com/zos/rmsportal/iGLmHkSxYfXveGhuzzFf.png"
    resultText=''
    autoFadeOut=true
    resultText="{{result}}"
    onFinish="onFinish"
  />
</view>
<!-- 其中,result 为动态获取的抽奖结果 -->

js

const app = getApp();
Page({
  data: {
    content: 'demo',
    result: ''
  },
  onLoad(options) {
    setTimeout(() => {
      this.setData({
        result: '很遗憾,差点就中奖了'
      });
    }, 1000);
  },
  onFinish() {
    console.log('刮奖结束了');
  }
});

效果图

高级用法

当抽奖结果显示为图片或需要自定义样式修饰时,可以传入slot,并将resultText值设置为''

<!-- 将 resultText 设置为空字符串 -->
<scratch resultText=''>
  <!-- 此处为 slot 子节点内容 -->
  <view class="result">
    <text>{{result}}</text>
  </view>
</scratch>

参数说明

属性 | 类型 | 默认值 | 含义 ---|---|---|--- id |String|scratch-canvas| 组件标识,页面唯一 width |Number|300|刮刮卡宽度,单位px height |Number|150|刮刮卡高度,单位px tipText |String|刮刮我,有惊喜|刮奖区域提示文字 tipColor |String|#aaa|提示文字的颜色 tipSize |Number|20|提示文字的字号,单位px lineWidth |Number|25|擦除线宽度,单位px activePercent |Number|0.4|当被擦除比例达到该值时刮奖结束,取值范围0-1 autoFadeOut |Boolean|true|当值为true且被擦除比例达到activePercent选项值时刮奖图层自动消失 ctxLogoUrl |String||刮奖区图片背景,小程序接口限制目前只支持线上cdn地址或离线包地址,cdn需返回头 Access-Control-Allow-Origin: * coverColor |String|#dbdbdb|刮奖区背景色,当背景图片透明度为0时无效 resultText |String|谢谢参与|刮奖结果 onFinish |Function|()=>{}|刮奖结束回调,当被擦除比例达到activePercent选项值时触发

由于小程序当前接口限制,暂不支持 rpxrem等像素单位,目前仅支持 px

开发