// 派发时间
var timestamp=1300000000;//服务下发的时间(10位)
if (timestamp && CustomEvent) {
const myEvent = new CustomEvent('serverTimeUpdate', {
detail: {
timestamp: parseInt(timestamp)
}
});
window.dispatchEvent(myEvent);
}
window.addEventListener('serverTimeUpdate',(e)=>{console.log(
if (e && e.detail && e.detail.timestamp) {
this.serverTime = e.detail.timestamp; //获取当前时间
} else {
this.serverTime = new Date() * 1 / 1000;
}
)})
网友评论