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

codelist

v0.1.5

Published

对ElementUI el-select二次封装

Downloads

4

Readme

codelist

基于ElementUI el-select二次封装的下拉框组件,结合后台字典表设计减少项目开发人员重复编写相同代码实现下拉框。 项目数据库设计有一张字典表,有字典编码值,字典名称,分类编码值等字段。 后端提供了一个公共接口通过分类的编码值,查询出该分类下所有数据。

后台接口说明

QueryPath: /common/dictionary/queryDictionarylistByTypeCode?typeCode=xxx
Method: GET
return
-----------------------------------------
{
	"code": "1",
	"data": [{
		"dictionaryCode": "2402",
		"dictionaryName": "地区"
	}, {
		"dictionaryCode": "2404",
		"dictionaryName": "混合"
	}, {
		"dictionaryCode": "2401",
		"dictionaryName": "国际"
	}, {
		"dictionaryCode": "2403",
		"dictionaryName": "国内"
	}],
	"msg": "成功"
}

前端使用方式

安装依赖

npm install codelist --save

Vue脚手架全局引用

//main.js中
import codelist from 'codelist'
Vue.use(codelist)

使用参数说明

  1. code: 为分类编码值
  2. v-model: 双向绑定的字典表编码值
  3. @select: 返回的是字典编码值与字典名称对象
  4. k: 返回数据下拉框指定的value值,默认dictionaryCode
  5. l: 返回数据下拉框指定的label值,默认为dictionaryName
  6. apiUrl: 可以改变默认的接口路径 /common/dictionary/queryDictionarylistByTypeCode
  7. data: 本地数据赋值给下拉框

使用举例

配置分类编码值发送到后台获取数据

<template>
  <div>
    <codelist code="region" v-model="code" @select="select" k="dictionaryCode" l="dictionaryName" apiUrl="/xx/xxx"></codelist>
  </div>
</template>
<script>
export default {
  name: 'App',
  data(){
    return{
      code:'2402'
    }
  },
  methods:{
    select(d){
      console.log(d)//{code: "2401", label: "国际"}
    }
  }
}
</script>

前台写死下拉框数据

<template>
  <div id="app">
      <codelist :data="sexList" v-model="sex" ></codelist>
  </div>
</template>

<script>

export default {
  name: 'App',
  data(){
    return{
      sexList:[{
        'dictionaryCode':'man',
        'dictionaryName':'男'
      },{
        'dictionaryCode':'woman',
        'dictionaryName':'女'
      }],
      sex:'man'
    }
  }
}
</script>

特性

默认集成了ElementUI el-select的clearable与filterable特性

<el-select :value="value" placeholder="请选择" @input="change($event)" filterable size="mini" clearable>
  //...省略
  </el-select>