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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@moluoxixi/select

v1.3.13

Published

Select 组件

Readme

Select 组件

基于Element Plus的Select选择器组件的二次封装,支持本地数据和远程接口数据源。

基本用法

<template>
  <Select v-model="value" :options="options" />
</template>

<script setup>
import { ref } from 'vue'
import { Select } from '@moluoxixi/components/Select'

const value = ref('')
const options = [
  { label: '选项1', value: '1' },
  { label: '选项2', value: '2' },
  { label: '选项3', value: '3' }
]
</script>

远程数据源

<template>
  <Select 
    v-model="value" 
    :serverProps="{ 
      serverType: 'base', 
      optionsParams: { dictType: 'COMMON_YES_NO' } 
    }" 
  />
</template>

<script setup>
import { ref } from 'vue'
import { Select } from '@moluoxixi/components/Select'

const value = ref('')
</script>

全局配置

在应用的入口文件(如main.ts)中,可以配置全局的远程数据源:

import { createApp } from 'vue'
import App from './App.vue'
import axios from 'axios'
import { configureServerOptions } from '@moluoxixi/components/Select/src/uitls'

// 配置Select组件的全局选项
configureServerOptions({
  // 配置服务类型和对应的API端点
  serverMap: {
    base: '/api/common/dict',
    users: '/api/users',
    departments: '/api/departments',
    // 添加更多自定义服务类型...
  },
  
  // 自定义请求处理函数
  requestHandler: async (url, params) => {
    try {
      // 使用axios或其他HTTP客户端
      const response = await axios.post(url, params)
      // 根据自己的API返回格式处理结果
      if (response.data.code === 200) {
        return response.data.data.list || []
      }
      return []
    } catch (error) {
      console.error('Failed to fetch options:', error)
      return []
    }
  }
})

const app = createApp(App)
app.mount('#app')

组件属性

| 属性名 | 说明 | 类型 | 默认值 | |--------|------|------|--------| | modelValue / v-model | 选中项绑定值 | string / number / boolean / object | — | | options | 下拉框选项数据 | Array | [] | | label | 选项标签的键名 | string | 'label' | | value | 选项值的键名 | string | 'value' | | clearable | 是否可以清空选项 | boolean | true | | filterable | 是否可搜索 | boolean | true | | filterMethod | 自定义搜索方法 | function | — | | collapseTags | 多选时是否将选中值按文字形式展示 | boolean | true | | collapseTagsTooltip | 当鼠标悬停于折叠标签的文本时,是否显示所有选中的标签 | boolean | true | | teleported | 是否将下拉菜单插入至body元素 | boolean | true | | serverProps | 远程数据源配置 | object | — |

serverProps 属性

| 属性名 | 说明 | 类型 | 默认值 | |--------|------|------|--------| | serverType | 服务类型,对应全局配置中的键名 | string | — | | optionsParams | 请求参数 | object | {} |

事件

| 事件名 | 说明 | 回调参数 | |--------|------|----------| | change | 选中值变化时触发 | 当前选中值 |