|
发表于 2024-3-20 10:09:16
|
显示全部楼层
解决了
var _this=this
function getnowdate(){
// 获取当前日期和时间
var now = new Date();
// 年
var year = now.getFullYear();
// 月,获取的时候要注意月份是从0开始的,所以实际显示的时候要加1,并且使用两位数字
var month = ('0' + (now.getMonth() + 1)).slice(-2);
// 日
var day = ('0' + now.getDate()).slice(-2);
// 时
var hours = ('0' + now.getHours()).slice(-2);
// 分
var minutes = ('0' + now.getMinutes()).slice(-2);
// 秒
var seconds = ('0' + now.getSeconds()).slice(-2);
// 格式化日期和时间
var formattedDate = year + '-' + month + '-' + day + ' ' + hours + ':' + minutes + ':' + seconds;
return formattedDate
}
_this.data.calendar_1 = getnowdate() 表单事件要用this.data赋值
而且很奇怪,为什么你们直接取this.data是会报错的,必须
var _this=this
_this.data.xx = 赋值
才可以,之前试了很多次this.data都不行才改用this.form.get
|
|