New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

vi-address

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vi-address

微信小程序地址三级联动组件

latest
Source
npmnpm
Version
0.0.1
Version published
Maintainers
1
Created
Source

微信小程序省市区三级联动组件

使用

npm i vi-address 使用微信开发者工具构建NPM并勾选使用NPM模块

打开小程序页面的json配置.

"usingComponents": {
  "vi-address": "/vi-address"
}

WXML结构

<view class="font14" bindtap='selectAddress'>点击选择城市: {{address}}</view>

<vi-address is-hide="{{isHide}}" bindhide="selectAddress" bindaddresschange="addressChange"></vi-address>

js逻辑

Page({
  data: {
    address: '',
    isHide: false
  },
  selectAddress(e) {
    this.setData({
      isHide: !this.data.isHide
    })
  },
  addressChange({ detail }) {
    this.setData({
      address: detail.detail.map(item => item.name).join('-')
    })
  }
})

属性 Props

接口数据类型说明选项默认值
isHideBoolean控制组件的显示与隐藏, false 隐藏, true 显示必填false
areaHideBoolean是否显示区/县, false 显示, true 隐藏选填false

事件 Events

事件方法事件说明detail 返回值
cancel组件的取消按钮或者是点击的遮罩层无返回值
confirm组件的确认按钮返回选择的城市
hide组件隐藏, cancel 与 confirm 都会触发该事件返回值为触发的事件源, 如:取消按钮触发的事件, 则返回值为 cancel
addresschange省市区选择事件只要有选择便会触发该事件, 组件初始化时会默认触发一次, 返回值为数组集合

Bug&Tips

  • 地址三级联动组件,显示与隐藏有默认动画,所以不需要给组件父级元素套一个处理动画的Propu组件
  • 该组件使用的选择器为微信小程序的 picker-view 内置组件, 所以对用户体验可能会存在一定影响
  • 由于是使用picker-view 内置组件,所以该组件暂无设置初始默认值的接口。目前正在尝试其他解决方式

Keywords

miniprogram

FAQs

Package last updated on 14 Sep 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts