Code Monkey home page Code Monkey logo

wx_selectarea's Introduction

Codacy Badge Dependency status Build Status GitHub issues

wx_selectArea

地址联动选择器采用微信小程序的 picker-view 组件

模板引入

提供 template 模板引入

1. 引入wxmlwxss

// example.wxml
<import src="../../template/index.wxml"/>
<template is="areaPicker" data="{{...areaPicker}}" />

// example.wxss
@import '../../template/index.wxss';

2. 组件初始化

import initAreaPicker, { getSelectedAreaData } from '../../template/index';

const conf = {
	onShow: () => {
    initAreaPicker();
  },
};

Page(conf);
2.1 自定义配置

目前仅支持是否隐藏第三极选择栏,默认显示

import initAreaPicker from '../../template/index';

const conf = {
	onShow: () => {
    initAreaPicker({
      hideDistrict: true,
    });
  },
};

Page(conf);
2.2 获取当前选择的省市区信息
import { getSelectedAreaData } from '../../template/index';

const conf = {
	btnClick() {
		console.table(getSelectedAreaData()); 
	},
};

Page(conf);

其他

API 请求地址在 config 文件夹中配置,GET 请求接口类似 https://your.com/api/area?code=123,服务端返回数据可参考例子中格式即可直接套用模板。

// request

http('https://your.com/api/area?code=0');

// response
{
    "message": "",
    "result": [
        {
            "code": 340000,
            "fullName": "安徽省",
            "mark": "",
            "outofrange": 0,
            "printMark": ""
        },
        {
            "code": 820000,
            "fullName": "澳门特别行政区",
            "mark": "",
            "outofrange": 0,
            "printMark": ""
        },
        ....
    ]
}

截图

wx_selectarea's People

Contributors

treadpit avatar codacy-badger avatar

Stargazers

 avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.