MUI dtpicker 如何产生联动效果

1.登录官网 下载demo,

 这是地址 http://dev.dcloud.net.cn/mui/

如下图,并不能发生级联效果:输入框的显示和隐藏到下方的容器 数据并不能同步

解决办法:

把下面这段代码copy到 html里,再点击试试

var data_value =document.getElementById(id).innerHTML ;
if(id == "demo1"){
	document.getElementById(id).setAttribute('data-options','{"value":"'+data_value+'"}');
}else if(id == "demo2"){
	document.getElementById(id).setAttribute('data-options','{"value":"'+data_value+'","type":"date"}');
}else if(id == "demo3"){
	document.getElementById(id).setAttribute('data-options','{"value":"'+data_value+'"}');
}else if(id == "demo4"){
	document.getElementById(id).setAttribute('data-options','{"value":"'+data_value+'","type":"date"}');
}else if(id == "demo5"){
	document.getElementById(id).setAttribute('data-options','{"value":"'+data_value+'","type":"time"}');
}else if(id == "demo6"){
	document.getElementById(id).setAttribute('data-options','{"value":"'+data_value+'","type":"month"}');
}else if(id == "demo7"){
	document.getElementById(id).setAttribute('data-options','{"value":"'+data_value+'","type":"hour",
     "customData":{"h":[{"text":"上午","value":"上午"},{"text":"下午","value":"下午"},
     {"text":"晚上","value":"晚上"}]},"labels":["年", "月", "日", "时段", "分"]}' ); }

 一看:

二看:

 

转载于:https://www.cnblogs.com/Li-Sun-Moon/p/9047093.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
HTML5+ 的 pickDate 和 MUIdtpicker 都是移动端时间控件,它们的使用和对比如下: 1. 使用方式: HTML5+ 的 pickDate 使用方式: ```html <input type="date" id="datePicker" /> ``` MUIdtpicker 使用方式: ```javascript var dtPicker = new mui.DtPicker({ type: "date", // 显示类型,可选值:date、datetime、time beginDate: new Date(2019, 0, 1), // 开始日期 endDate: new Date(2022, 11, 31), // 结束日期 labels: ["年", "月", "日", "时", "分"], // 按钮上的文字 customData: { h: [ { value: "0", text: "0时" }, { value: "1", text: "1时" }, { value: "2", text: "2时" }, { value: "3", text: "3时" }, { value: "4", text: "4时" }, { value: "5", text: "5时" }, { value: "6", text: "6时" }, { value: "7", text: "7时" }, { value: "8", text: "8时" }, { value: "9", text: "9时" }, { value: "10", text: "10时" }, { value: "11", text: "11时" }, { value: "12", text: "12时" }, { value: "13", text: "13时" }, { value: "14", text: "14时" }, { value: "15", text: "15时" }, { value: "16", text: "16时" }, { value: "17", text: "17时" }, { value: "18", text: "18时" }, { value: "19", text: "19时" }, { value: "20", text: "20时" }, { value: "21", text: "21时" }, { value: "22", text: "22时" }, { value: "23", text: "23时" } ], min: [ { value: "0", text: "00分" }, { value: "10", text: "10分" }, { value: "20", text: "20分" }, { value: "30", text: "30分" }, { value: "40", text: "40分" }, { value: "50", text: "50分" } ] } }); ``` 2. 功能特点: HTML5+ 的 pickDate 可以简单的显示日期选择器,支持原生的日期格式,但是其样式无法自定义,功能比较简单。 MUIdtpicker 支持日期、时间、日期时间三种类型的选择器,支持自定义样式和文字,支持自定义可选项,功能比较丰富。 3. 兼容性: HTML5+ 的 pickDate 兼容性较差,只有在支持 HTML5+ 的浏览器和 Webview 下才能正常显示。 MUIdtpicker 兼容性较好,支持 iOS 和 Android 平台,同时也支持在 Webview 中使用。 综上所述,如果需要功能比较简单的日期选择器,可以使用 HTML5+ 的 pickDate,如果需要功能比较丰富的日期选择器,可以使用 MUIdtpicker

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值