微信小程序,下拉框组件
微信小程序-小程序开发
这篇文章主要为大家详细介绍了微信小程序下拉框组件的使用方法,写的十分的全面细致,具有一定的参考价值,对此有需要的朋友可以参考学习下。如有不足之处,欢迎批评指正。【推荐教学:小程序开发教学】特效小熊源码,vscode滚轮字体大小,ubuntu 共享 硬盘,tomcat集群同步数据,数据爬虫交易,php获取file路径,永泰效果好的seo推广,修改WordPress网站,简单的网站模板lzw
适用场景什么网站有网站源码,函数换行处理vscode,ubuntu下死机,tomcat卸不掉,sqlite数据库句柄,如何用python爬虫收集数据,php 获取当前的小时,韩国模特jiny seo,简洁大方的购物网站,网页换肤布局,bootstrap h5模板网站lzw
1、省市三级联动2、出生日期选择
3、性别选择
4、一般性的下拉选择等
h5传奇之境源码,vscode关键字,ceph ubuntu搭建,tomcat怎么找jdk,unity 爬虫,php 魔术函数,黑帽seo的优化,dede网站怎么更换模板,discuz段子模板lzw
A、省市三级联动使用注意mode = region,以及value = “一维数组”
//.wxml 当前选择:{{region[0]}},{{region[1]}},{{region[2]}}
B、出生日期选择
注意mode = date,以及value = “日期字符串”
{{date}}
C、性别选择
{{gender[index]}}
以上都需要在.js里设置相关初始变量!
var app = getApp(); data: { region:['湖南','长沙','岳麓'], date:'2010-10-10', gender:['男','女'], index:0 } bindViewEvent:function(e){ app.process(this,e); }
相关js类
//component.jsconst select = require('../component/select.js');const upload = require('../component/upload.js');class component{ constructor(com, that) { this.com = com; this.that = that; } //绑定下拉框选择事件 bindSelect(data){ let self = this; let mode = data.currentTarget.dataset.mode; let name = data.currentTarget.dataset.name; let picker = new select({ that: self.that, mode: mode, name: name }); picker.change(data.detail.value); } //点击事件,传递参数为e.currentTarget.dataset bindImageChoose(data){ //图片上传 this.uploader = new upload({ that: that, name: data.name, mode: data.mode, count: data.count || 9 }); this.uploader.choose(); } bindImageDel(data){ //图片上传 this.uploader = new upload({ that: that, name: data.name, mode: data.mode, count: data.count || 9 }); this.uploader.del(data.index); }}module.exports = component;//select.js/** 下拉框对象*/class picker{ constructor(data){ this.that = data.that; this.name = data.name || 'date'; this.mode = data.mode || 'selector'; } show(name,data){ let view = {}; view[name] = data; this.that.setData(view); } change(data){ let self = this; self.show(self.name, data); }}module.exports = picker;//upload.jsclass picUploader { constructor(data) { this.that = data.that; this.name = data.name; this.mode = data.mode || 1; this.count = this.model == 1 ? 1 : data.count || 9; } /* * 选择图片 */ choose() { const self = this; wx.chooseImage({ count: (self.count - self.that.data[self.name].length), sizeType: ['original', 'compressed'], sourceType: ['album', 'camera'], success: function (res) { var tempFilePaths = res.tempFilePaths; self.append(tempFilePaths); } }) } /* * 显示图片 */ show() { let self = this; let view = {}; view[self.name] = self.that.data[self.name]; self.that.setData(view); } /* * 追加图片 */ append(data) { const self = this; for (let i = 0; i < data.length; i++) { self.that.data[self.name].push(data[i]); } self.show(); } /* * 删除图片 */ del(index) { let self = this; self.that.data[self.name].splice(index, 1); self.show(); }}module.exports = picUploader;