一、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)
}
})

微信小程序开发--组件(4)的更多相关文章

  1. 微信小程序开发--组件(5)

    一.editor 富文本编辑器,可以对图片.文字进行编辑. 编辑器导出内容支持带标签的 html和纯文本的 text,编辑器内部采用 delta 格式进行存储. 通过setContents接口设置内容 ...

  2. 微信小程序开发--组件(3)

    一.radio <radio-group class="radio-group" bindchange="radioChange"> <lab ...

  3. 微信小程序开发05-日历组件的实现

    接上文:微信小程序开发04-打造自己的UI库 github地址:https://github.com/yexiaochai/wxdemo 我们这里继续实现我们的日历组件,这个日历组件稍微有点特殊,算是 ...

  4. 微信小程序开发03-这是一个组件

    编写组件 基本结构 接上文:微信小程序开发02-小程序基本介绍 我们今天先来实现这个弹出层: 之前这个组件是一个容器类组件,弹出层可设置载入的html结构,然后再设置各种事件即可,这种组件有一个特点: ...

  5. 微信小程序倒计时组件开发

    今天给大家带来微信小程序倒计时组件具体开发步骤: 先来看下最终效果: git源:http://git.oschina.net/dotton/CountDown 分步骤-性子急的朋友,可以直接看最后那段 ...

  6. 微信小程序开发心得

    微信小程序也已出来有一段时间了,最近写了几款微信小程序项目,今天来说说感受. 首先开发一款微信小程序,最主要的就是针对于公司来运营的,因为,在申请appid(微信小程序ID号)时候,需要填写相关的公司 ...

  7. 微信小程序开发日记——高仿知乎日报(下)

    本人对知乎日报是情有独钟,看我的博客和github就知道了,写了几个不同技术类型的知乎日报APP 要做微信小程序首先要对html,css,js有一定的基础,还有对微信小程序的API也要非常熟悉 我将该 ...

  8. 微信小程序开发日记——高仿知乎日报(中)

    本人对知乎日报是情有独钟,看我的博客和github就知道了,写了几个不同技术类型的知乎日报APP要做微信小程序首先要对html,css,js有一定的基础,还有对微信小程序的API也要非常熟悉 我将该教 ...

  9. 微信小程序开发日记——高仿知乎日报(上)

    本人对知乎日报是情有独钟,看我的博客和github就知道了,写了几个不同技术类型的知乎日报APP 要做微信小程序首先要对html,css,js有一定的基础,还有对微信小程序的API也要非常熟悉 我将该 ...

随机推荐

  1. linux安装脚本

    1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 3 ...

  2. linux下计划任务学习记录

    0x01 计划任务简介 linux 中计划任务主要分为”循环执行”和”只执行一次”两种,分别对应的时 crond 服务 和 atd 服务: 0x02 只执行一次的计划任务 0x02.1 atd 服务说 ...

  3. 一键彻底关闭Win10自带Windows Defender杀毒软件

    1.以管理员身份打开系统的命令提示符[cmd.exe]. 2.输入以下命令: reg add "HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\ ...

  4. oracle 12c连接pdb

    12c中,如何连接pluggable database: 使用默认的service连接pdb,创建pdb之后,在监听中自动添加以pdb为名的service: 用户在cluster中创建service, ...

  5. delphi 获取当前进程的cpu占用率

    type  TProcessCpuUsage = record  private    FLastUsed, FLastTime: Int64;    FCpuCount:Integer;  publ ...

  6. 解决C/C++程序执行一闪而过的方法(使用getchar,或者cin.get,不推荐system(“pause”))

    简述 在VS编写控制台程序的时候,包括使用其他IDE(Visual C++)编写C/C++程序,经常会看到程序的执行结果一闪而过,要解决这个问题,可以在代码的最后加上system(“pause”).g ...

  7. python中的基本数据类型之列表,元组

    一.列表 1.什么是列表. 列表是python的基本数据类型之一,用[]来表示,可以存放各种数据类型(什么都能装,能装对象的对象) 列表相比于字符串,不仅可以存放不同类型的数据,而且可以存放大量的数据 ...

  8. IO多路复用与异步非阻塞

    1.基于socket,发送http请求 import socket import requests # 方式一 list=['li','gh ','nn'] for i in list: ret=re ...

  9. JVM底层实现与总结

    一.类加载器 1.BootstrapClassLoader(启动类加载器) 它主要负责加载%JAVA_HOME%/jre/lib,-Xbootclasspath参数指定的路径以及%JAVA_HOME% ...

  10. 报错:java.sql.SQLException: The server

    报错:java.sql.SQLException: The server time zone value '�й���׼ʱ��' is unrecognized 在IDEA运行是报出例如相识的错误时: ...