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

chuck-cascader

v1.1.1

Published

支持多选的移动端级联选择器

Downloads

10

Readme

介绍

由于很多移动端组件库例如vant、nutui、cube等并不支持多选的级联选择器,于是一个基于vue3开发的支持多选的移动端级联选择器诞生了。

预览

https://chuckchen88.github.io/chuck-cascader/

安装

$ npm i chuck-cascader@latest

使用

# 局部使用 ChuckSearch, CheckBox, RadioBox 这三个组件也暴露出来了 按需使用
$ import { ChuckCascader } from 'chuck-cascader';
$ import "chuck-cascader/css"; # 注意需要引入css

# 全局注册
$ import ChuckCascader from 'chuck-cascader';
$ import "chuck-cascader/css"; # 注意需要引入css
$ Vue.use(ChuckCascader)

ChuckCascader参数说明

|参数|类型|是否必传|说明| |-|-|-|-| |v-model|string|string[]|否|多选时是数组,单选时是字符串| |options|CascaderOption[]|是|选项| |multiple|boolean|否|是否多选,默认false| |color|string|否|主题颜色,默认'#1989fa'| |title|string|否|下拉标题,默认'请选择'| |height|string|否|下拉选项高度,默认'250px'| |zIndex|number|否|下拉选项的zIndex,默认2023| |filterable|boolean|否|是否支持搜索,默认true|

CascaderOption[]

interface CascaderOption{
    label: string
    value: string | number
    children?: CascaderOption[]
    disabled?: boolean
}

事件

|事件名称|类型|默认值|说明| |-|-|-|-| |on-update:value|(value: string | number | Array<string | number> | null, option: CascaderOption | Array<CascaderOption | null> | null) => void|undefined|值改变时执行的回调| |on-confirm|() => void|undefined|点击了确认回调|

异步展开或收起

const cascaderRef = ref<any>(null)
// 展开
cascaderRef.value.expand(true)
// 收起
cascaderRef.value.expand(false)

vue3中使用示例

<script setup lang="ts">
import { ChuckCascader, ChuckSearch, CheckBox, RadioBox } from 'chuck-cascader';
import "chuck-cascader/css";
import { ref } from 'vue'
interface CascaderOption{
    label: string
    value: string | number
    disabled?: boolean
    children?: CascaderOption[]
}
const value = ref([]) // 双向绑定
const options = ref<CascaderOption[]>([]) // 选项

function getOptions (depth = 3, iterator = 1, prefix = '') {
  const length = 12
  const options: CascaderOption[] = []
  for (let i = 1; i <= length; ++i) {
    if (iterator === 1) {
      options.push({
        value: `v-${i}`,
        label: `l-${i}`,
        disabled: i % 5 === 0,
        children: getOptions(depth, iterator + 1, '' + String(i))
      })
    } else if (iterator === depth) {
      options.push({
        value: `v-${prefix}-${i}`,
        label: `l-${prefix}-${i}`,
        disabled: i % 5 === 0
      })
    } else {
      options.push({
        value: `v-${prefix}-${i}`,
        label: `l-${prefix}-${i}`,
        disabled: i % 5 === 0,
        children: getOptions(depth, iterator + 1, `${prefix}-${i}`)
      })
    }
  }
  return options
}

options.value = getOptions()

const onUpdateValue = (value: string[], options: CascaderOption[]) => {
  console.log(value) // 选中的
  console.log(options) // 选中的
}
const confirm = () => {
  console.log('点击了确认')
}
const filterValue = ref('') // 双向绑定
const checked = ref(true)
</script>

<template>
  搜索框:
  <ChuckSearch v-model="filterValue" />
  CheckBox:
  <CheckBox color="#1989fa" v-model="checked" :childChecked="false" :disabled="false" @update:value="(_e: any) => {}" />
  RadioBox:
  <RadioBox color="#1989fa" v-model="checked" :disabled="false" :showNext="true" /> 
  级联:
  <ChuckCascader
    :options="options"
    :multiple="true"
    color="#1989fa"
    title="请选择"
    v-model="value"
    @update:value="onUpdateValue"
    height="250px"
    :zIndex="9999"
    :filterable="true"
    @confirm="confirm"
  />
</template>

<style lang="less">
  body{
    margin:0;
    padding:0;
  }
</style>