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

bovine-city-selector

v1.1.1

Published

无依赖的城市选择器

Downloads

4

Readme

bovine-city-selector

城市选择器插件

优点

  1. 体积小,更轻量(最终打包生成的文件 12KB,再加上依赖的城市 JSON 文件一共 62KB);
  2. 兼容性好,兼容目前市面上所有有兼容必要的浏览器,包括移动端;
  3. 配置项多,更个性化;

安装

  1. npm 安装:
npm install bovine-city-selector --save-dev
  1. 引入方式
全局变量:
window.CitySelector
commonjs:
const CitySelector = require("bovine-city-selector")
es6:
import CitySelector from "bovine-city-selector";
  1. 引入官方 css 样式
<link rel="stylesheet" href="引入路径/bovine-city-selector/dist/city-selector.css" />

用法

基本用法:

html:

<div class="city-selector-container">
	<input type="text" data-type="city-selector" class="city-selector-input" placeholder="请选择所在城市" />
</div>

js:

var citySelectorContainer = document.querySelector(".city-selector-container")
var citySel = new CitySelector(citySelectorContainer)
简易展示数据:

html (input 添加自定义属性 data-simple="true")

<div class="city-selector-container">
	<input
		type="text"
		data-type="city-selector"
		data-simple="true"
		class="city-selector-input"
		placeholder="请选择所在城市"
	/>
</div>
强制获取地址:

html (input 添加自定义属性 data-force="true")

<div class="city-selector-container">
	<input
		type="text"
		data-type="city-selector"
		data-force="true"
		class="city-selector-input"
		placeholder="请选择所在城市"
	/>
</div>

参数:

| 参数名 | 类型 | 默认值 | 备注 | | :---------: | :----: | :----------------------------------------------------------: | :--------: | | defaultData | Object | province(省份),city(城市),district(地区) | 默认城市 | | actionName | Object | title(选择器名称),cancelBtn(取消按钮),confirmBtn(确认按钮) | 自定义信息 | | tabs | Array | | tab 栏标签 | | errorTips | Object | noPro(未选省份),noCity(未选城市),noDis(未选区域) | 错误提示 |

API:

confirm():参数:data。点击确定后返回用户选择的城市对象,以供作自定义处理。

cancel():用户点击取消按钮后响应的事件。