首页 技术 正文
技术 2022年11月14日
0 收藏 771 点赞 2,733 浏览 3621 个字

一、picker-view / picker-view-column

<view>
<view>{{year}}年{{month}}月{{day}}日</view>
<picker-view indicator-style="height: 50px;" style="width: 100%; height: 300px;" value="{{value}}" bindchange="bindChange">
<picker-view-column>
<view wx:for="{{years}}" style="line-height: 50px"wx:key="">{{item}}年</view>
</picker-view-column>
<picker-view-column>
<view wx:for="{{months}}" style="line-height: 50px"wx:key="">{{item}}月</view>
</picker-view-column>
<picker-view-column>
<view wx:for="{{days}}" style="line-height: 50px" wx:key="">{{item}}日</view>
</picker-view-column>
</picker-view>
</view>
<!--
value Array.<number> 数组中的数字依次表示 picker-view 内的 picker-view-column 选择的第几项(下标从 开始),数字大于 picker-view-column 可选项长度时,选择最后一项。 1.0.
indicator-style string 设置选择器中间选中框的样式 1.0.
indicator-class string 设置选择器中间选中框的类名 1.1.
mask-style string 设置蒙层的样式 1.5.
mask-class string 设置蒙层的类名 1.5.
bindchange eventhandle 滚动选择时触发change事件,event.detail = {value};value为数组,表示 picker-view 内的 picker-view-column 当前选择的是第几项(下标从 开始) 1.0.
bindpickstart eventhandle 当滚动选择开始时候触发事件 2.3.
bindpickend eventhandle 当滚动选择结束时候触发事件
-->
//index.js
//获取应用实例
const date = new Date()
const years = []
const months = []
const days = []for (let i = ; i <= date.getFullYear(); i++) {
years.push(i)
}for (let i = ; i <= ; i++) {
months.push(i)
}for (let i = ; i <= ; i++) {
days.push(i)
}Page({
data: {
years: years,
year: date.getFullYear(),
months: months,
month: ,
days: days,
day: ,
value: [, , ],
// 数组中的三个元素分别表示:1、年份下标、月份下标、日期下标
},
bindChange: function (e) {
const val = e.detail.value
this.setData({
year: this.data.years[val[]],
month: this.data.months[val[]],
day: this.data.days[val[]]
})
}
})

二、textarea

<view class="content">
</view>
<view class="section">
<textarea bindblur="bindTextAreaBlur" auto-height placeholder="自动变高" />
</view>
<view class="section">
<textarea placeholder="placeholder颜色是红色的" placeholder-style="color:red;" />
</view>
<view class="section">
<textarea placeholder="这是一个可以自动聚焦的textarea" auto-focus />
</view>
<view class="section">
<textarea placeholder="这个只有在按钮点击的时候才聚焦" focus="{{focus}}" />
<view class="btn-area">
<button bindtap="bindButtonTap">使得输入框获取焦点</button>
</view>
</view>
<view class="section">
<form bindsubmit="bindFormSubmit">
<textarea placeholder="form 中的 textarea" name="textarea" />
<button form-type="submit"> 提交 </button>
</form>
</view>
<!--
value string 输入框的内容 1.0.
placeholder string 输入框为空时占位符 1.0.
placeholder-style string 指定 placeholder 的样式,目前仅支持color,font-size和font-weight 1.0.
placeholder-class string textarea-placeholder 否 指定 placeholder 的样式类 1.0.
disabled boolean 是否禁用 1.0.
maxlength number 最大输入长度,设置为 - 的时候不限制最大长度 1.0.
auto-focus boolean 自动聚焦,拉起键盘。 1.0.
focus boolean 获取焦点 1.0.
auto-height boolean 是否自动增高,设置auto-height时,style.height不生效 1.0.
fixed boolean false 如果 textarea 是在一个 position:fixed 的区域,需要显示指定属性 fixed 为 true 1.0.
cursor-spacing number 指定光标与键盘的距离。取textarea距离底部的距离和cursor-spacing指定的距离的最小值作为光标与键盘的距离
cursor number 指定focus时的光标位置 1.5.
show-confirm-bar boolean 是否显示键盘上方带有”完成“按钮那一栏 1.6.
selection-start number 光标起始位置,自动聚集时有效,需与selection-end搭配使用 1.9.
selection-end number 光标结束位置,自动聚集时有效,需与selection-start搭配使用 1.9.
adjust-position boolean 键盘弹起时,是否自动上推页面 1.9.
bindfocus eventhandle 输入框聚焦时触发,event.detail = { value, height },height 为键盘高度,在基础库 1.9. 起支持
bindblur eventhandle 输入框失去焦点时触发,event.detail = {value, cursor} 1.0.
bindlinechange eventhandle 输入框行数变化时调用,event.detail = {height: , heightRpx: , lineCount: } 1.0.
bindinput eventhandle 当键盘输入时,触发 input 事件,event.detail = {value, cursor, keyCode},keyCode 为键值,目前工具还不支持返回keyCode参数。bindinput 处理函数的返回值并不会反映到 textarea 上 1.0.
bindconfirm eventhandle 点击完成时, 触发 confirm 事件,event.detail = {value: value} 1.0.
bindkeyboardheightchange eventhandle 键盘高度发生变化的时候触发此事件,event.detail = {height: height, duration: duration
-->
//textarea.js
Page({
data: {
height: ,
focus: false
},
bindButtonTap: function () {
this.setData({
focus: true
})
},
bindTextAreaBlur: function (e) {
console.log(e.detail.value)
},
bindFormSubmit: function (e) {
console.log(e.detail.value.textarea)
}
})
相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:9,491
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,907
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,740
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,493
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:8,132
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:5,294