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

v_region_selector

v0.0.5

Published

A region selector based on Vue2, Vuex and element UI

Downloads

9

Readme

v_region_selector [by Saturnus]

A region selector based on Vue2, Vuex and element UI

Install

npm i v_region_selector -S

Usage

Global Registration

import Vue from 'vue'
import store from 'vuex' // you must install vuex first

import RegionSelector from 'v_region_selector'
Vue.use(RegionSelector, { store })

Using the component

<region-selector
  ref="regionSelector"
  v-model="regionList"
  :requestList="requestList"
  responseKey="resultJson"
  :keyMapList="keyMapList"
/>

<script>
import request from '@/network' // axios

export default {
  data() {
    return {
      regionList: [
        // "110000", "110100", "110101" // default value
      ],
      keyMapList: [
        ['provinceId', 'provinceName'],
        ['cityId', 'cityName'],
        ['areaId', 'areaName']
      ]
    }
  },
  computed: {
    requestList: function (){
      const that = this
      const req_province = function() {
        return new Promise(resolve => {
          request.post(
            'commonApi/common/getProvince', // your request
            {} // parameter
          ).then(res => {
            resolve(res)
          })
        })
      }
      const req_city = function() {
        return new Promise(resolve => {
          request.post(
            'commonApi/common/getCity',
            {
              provinceId: that.regionList[0] // 请求的入参
            }
          ).then(res => {
            resolve(res)
          })
        })
      }
      const req_district = function() {
        return new Promise(resolve => {
          request.post(
            'commonApi/common/getArea',
            {
              cityId: that.regionList[1] // 请求的入参
            }
          ).then(res => {
            resolve(res)
          })
        })
      }
      return [
        req_province, // 获取 第一级别 地址 接口请求 promise
        req_city, // 获取 第二级别 地址 接口请求 promise
        req_district // 获取 第三级别 地址 接口请求 promise
      ]
    }
  },
  methods: {
    getVal: function () {
      // console.info(this.$refs['regionSelector'].getValue()) // bad
      console.info(this.regionList) // good
    },
    setVal: function () {
      // this.$refs['regionSelector'].setValue([ '150000', '150200', '150203' ]) // bad
      this.regionList = [ '150000', '150200', '150203' ] // good
    },
    reset: function () {
      // this.$refs['regionSelector'].setValue([ '', '', '' ]) // bad
      this.regionList = [] // good
    }
  }
}
</script>

Props

| Name | Type | Default | Options | Description | | ----------- | ------- | ------------------------------ | -------------------- | ------------------------------------------------------------ | | v-model | Array | [] | | value | | layoutDir | String | horizontal | horizontal, vertical | | | labelShow | Boolean | true | | show label or not | | labelWidth | String | 50px | | | | labelAlign | String | right | left, center, right | | | requestList | Array | | | the request list | | responseKey | String | '' | | key of the data in response | | keyMapList | Array | [['id', 'name'], [...], [...]] | | it`s hard to descripe in English...(select 的 option 需要 key 和 value,默认 key 是 id,value 是 name。如果您的接口返回值地址数据与默认不同,请参考返回值进行配置。如:[['provinceId', 'provinceName'], ['cityId', 'cityName'], ['areaId', 'areaName']]) |

Methods

| Name | Description | e.g. | | -------- | ------------------------------------------------------ | ------------------------------------------------------------ | | getValue | return value like['150000', '150200', '150203' ] | this.$refs['regionSelector'].getValue() | | setValue | | this.$refs['regionSelector'].setValue([ '150000', '150200', '150203' ]) |

Events

| Name | Description | e.g. | | ---- | ----------- | ---- | | / | / | / |

Build Setup

# install dependencies
npm install

# serve with hot reload at localhost:8081
npm run dev

# build for production with minification
npm run build

License

MIT