城市选择器

城市选择器

模块

  • pmuiCitypicker

模块引入

  • Weex

const citypicker = app.requireModule('pmuiCitypicker');

  • H5

let citypicker = requireModuleJs('pmuiCitypicker');

方法

  • select(params,callback)
    • params 参数字典,数据格式如下
key 类型 Demo 描述
params dictionary {key:value} 离线包页面相关参数

实例代码

<template>
    <div class="app">

        <text class="button" @click="citypicker">选择城市</text>
        <text>{{province}} {{city}} {{area}}</text>

    </div>
</template>

<style>
    .app {
        flex: 1;
        justify-content: center;
        align-items: center;
    }
    .button {
        text-align: center;
        margin-top: 20px;
        padding-top: 20px;
        padding-bottom: 20px;
        width: 220px;
        color: #ffffff;
        background-color: #00B4FF;
    }
</style>

<script>
    const citypicker = app.requireModule('pmuiCitypicker');

    export default {
        data() {
            return {
                province: '浙江省',    //省份
                city: '杭州',          //城市
                area: '市辖区',        //区县
                areaOther: false,     //是否加上其它区(可选参数)
            }
        },
        methods: {
            citypicker() {
                citypicker.select({
                    province: this.province,
                    city: this.city,
                    area: this.area
                }, (result) => {
                    this.province = result.province;
                    this.city = result.city;
                    this.area = result.area;
                });
            }
        }
    };
</script>