js 异步
作者:互联网
var fnParam = null;
var a = {
fn: param => {
// 加载真实函数
fnParam = param;
}
};
var pm = () =>
new Promise(resolve => {
a.fn({
callback(data) {
console.log('使用方fn参数callback执行,resolve执行');
resolve(data);
}
});
});
pm().then(a => {
console.log(a, 'fn 回调的值');
});
setTimeout(() => {
// fn 加载完成
a.fn = p => {
if (p.callback) {
p.callback({
a: 'a',
b: 'b',
c: 'c'
});
}
};
a.fn(fnParam);
}, 2000);
标签:异步,resolve,console,js,fnParam,callback,var,fn 来源: https://www.cnblogs.com/Running00/p/16576141.html