|
我在写请假时间的时候要先判断该天是否是节假日,所以我得先去获取法定假期的数据
但是我获取以后我用了如下两种js方法用了以后数据表单都不能显示数据
1:
在change时间中的使用时间延迟的方法
setTimeout(function leave() { this.data.add("result",6.5,true) }, 1000);
结果是debugger能看到数据,但是表单上不显示
2:
在change事件中使用异步方法
var holidays=[]
var that=this
debugger
getqw()
console.log('nihao');
debugger
//获取节假日把指定ID的的框中显示内容
async function getqw() {
await getqwTime();
debugger
console.log(holidays.length)
//我在这儿显示内容但是也不会显示在表单中
this.data.result=6.5
debugger
}
//异步获取节假日
async function getqwTime() {
return new Promise((resolve) => {
var action = that.Actions.load("x_attendance_assemble_control");
action.AttendanceWorkDayConfigAction.listAllAttendanceWorkDayConfig(//平台封装好的方法
function( json ){ //服务调用成功的回调函数, json为服务传回的数据
data = json.data; //为变量data赋值
console.log(data)
console.log(data.length)
for(var i=0;i<data.length;i++){
holidays.push(data.configDate)
}
resolve()
console.log('holidays',holidays)
}.bind(this),
function( json ){ //服务调用失败的回调函数, json为服务传回的数据
data = json.data; //为变量data赋值
}.bind(this)
);
})
};
请你帮我看看。我要处理这种异步的情况应该怎么办????
|
|