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

turntable_v1

v1.0.3

Published

转盘组件

Downloads

2

Readme

使用

npm install turntable_v1

方式二:
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/vue.js"></script>
<script src="http:xxx/dist/turntable.umd.js"></script>
需要注意 <Turntable ref="myRotate" :styles="styles" @getprizeinfo="getPrizeInfo" />
 @getprizeinfo 不能使用驼峰
 const { ref } = Vue
 new Vue({
    el: '#app',
    setup() {
        let styles = {}
        const myRotate = ref(null);

        function getPrizeInfo() {
            //ajax
            myRotate.value.startRotate(result, function(res) {
                console.log(res.txt);
            });
        }
        return { styles, getPrizeInfo,myRotate }
    },
})
 

样式传参

  转盘 可能 分三层(底层/奖品层/点击旋转指针层)或者两层(奖品层/点击旋转指针层)
  r1:底层---没有可以传空对象
  r2:奖品层 
  r3:指针层

样式传参示例

  const styles = {
      r1: {//无背景 传空对象 必填
        w: "16rem",
        h: "16rem",
        img: require("./img/r1.png"),
      },
      r2: {
        w: "15rem",
        h: "15rem",
        img: require("./img/r2.png"),
        (选填)isBtn:0,//参数 1/2/3 1:按钮在中间指针上  2:按钮在中间奖品盘上  3.按钮在外部 默认参数1
      },
      r3: {
        w: "3.6rem",
        h: "4.225rem",
        img: require("./img/r3.png"),
        (选填)isBtn:0,//参数 1/2/3 1:按钮在中间指针上  2:按钮在中间奖品盘上  3.按钮在外部 默认参数1
        (选填)top:0,//指针的位置 上下
        (选填)left:0,//指针的位置 左右
      },
    };

功能传参

   <Turntable ref="myRotate" :styles="styles" @getPrizeInfo="getPrizeInfo" />

   ## 点击按钮触发 getPrizeInfo事件
    function getPrizeInfo() {
      //ajax获取奖品名称或者奖品id 赋值给data 
      let data = "5";
      let result;
      switch (data) {
        case "1": //这里传奖品名称 或者 id 随意配置
          result = { deg: 0, txt: "100元" };
          break;
        case "2":
          result = { deg: 60, txt: "机油" };
          break;
        case "3":
          result = { deg: 120, txt: "8折工时券" };
          break;
        case "4":
          result = { deg: 180, txt: "空气滤芯1只" };
          break;
        case "5":
          result = { deg: 240, txt: "机油滤清器1只" };
          break;
        default:
          result = { deg: 30, txt: "很遗憾,你未中奖" };
          break;
      }
      ### 调用子组件start方法 传参 result.deg和回调函数 必传
      myRotate.start(result, function (res) {
        alert(res.txt);
      });
    }

开发组件二 单包开发 基于vue-cli构建目标vue-cli-service build --target lib --name myLib [entry]

创建项目

 vue create 项目名
 配置

第一步

  新建文件夹目录 本地预览可随意(改成examples文件名作为本地预览)
  组件放在目录packages(这个就放src下)
  src 下 放一个全局导出的js 一样通过install注册组件 use使用

第二步

配置打包 package.json 
需要配置 "version"::"版本"
	    "private": false
	    "main": "dist/test.umd.js",主入口文件

新加打包命令“lib”:
    "serve": "vue-cli-service serve",
    "build": "vue-cli-service build",
    "lint": "vue-cli-service lint",
    "lib": "vue-cli-service build --target lib --name test src/index.js"