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 🙏

© 2025 – Pkg Stats / Ryan Hefner

vue-onoffs

v1.0.2

Published

基于vue的开关组件库

Downloads

8

Readme

基于vue的一款开关组件

文档

举例

这里主要以第一个默认组件为例子 来举例如何调用使用 组件名为 OnOff.vue

具体组件API查看下面文档

一 使用方法

  • 安装组件

    npm i vue-onoffs -S
  • 注册组件 在vue main.js中加入如下代码

    import VueOnoffs from 'vue-onoffs'
    Vue.use(VueOnoffs)
    Vue.prototype.VueOnoffs = VueOnoffs

二 通用初始化步骤

  • 初始化组件

    data () {
      return {
        onOff: this.VueOnoffs.OnOff.empty({
            width: 50,
            height: 32,
            borderWidth: 2,
        })
      }
    }
  • 绑定data对象

    <OnOff :value="onOff" @change="changeOnOff"/>
  • 监听组件变更 change

    changeOnOff (obj) {
    	let { OnOff } = this.VueOnoffs
    	this.onOff = OnOff.Logic.update(OnOff.Logic.switchoverStatus(obj))      
    }

三 组件相关API

  • OnOff.vue

    props

    | Options | Type | Description | Default | | :------ | :------:| :------:| :------: | | width | Number | 开关宽度 | 100 | | height | Number | 开关高度 | 64 | | borderWidth | Number | 开关描边 | 4 | | status | Boolean | 开关状态 默认true | true | | startColor | Object | 开始开关颜色 | 查看 startColor | | endColor | Object | 开始开关颜色 | 查看 endColor |

    startColor

    | Options | Type | Description | Default | | :------ | :------:| :------:| :------: | | strokeStyle | String | 开关边框色 | rgb(235,235,235) | | fillStyle | String | 开关背景色 | rgba(255,255,255,1) | | defaultArcBdColor | Number | 圆形背景色 | rgba(255,255,255,1) | | shadowObj | Object | 开始开关阴影色 | {"shadowColor":"rgba(0,0,0,0.14)","shadowBlur":6,"shadowOffsetX":3,"shadowOffsetY":2} |

    endColor

    | Options | Type | Description | Default | | :------ | :------:| :------:| :------: | | strokeStyle | String | 开关边框色 | rgba(75,217,100,1) | | fillStyle | String | 开关背景色 | rgba(75,217,100,1) | | defaultArcBdColor | Number | 圆形背景色 | rgba(255,255,255,1) | | shadowObj | Object | 开始开关阴影色 | {"shadowColor":"rgba(20,149,43,0.83)","shadowBlur":6,"shadowOffsetX":-3,"shadowOffsetY":2} |

    methods
    empty

    初始化props 用法如下

    this.VueOnoffs.OnOff.empty({
        width: 50,
        height: 32,
        borderWidth: 2
    })
    Logic

    | Options | Type | Description | Default | | :------ | :------:| :------:| :------: | | update | Function | 更新props| {} | | switchoverStatus | Function | 获得开关切换状态 | props |

    用法如下

    let { OnOff } = this.VueOnoffs
    OnOff.Logic.update() // 更新props
    let { OnOff } = this.VueOnoffs
    OnOff.Logic.switchoverStatus(obj) // 更新切换状态