function1: function () {
return new Promise(function (resolve, reject) {
manager.stop()
resolve();
})
},
function2: function () {
var that = this;
that.function1().then(function (resolve) {
console.log("globalData2", app.globalData.result)
var result = getApp().globalData.result
that.setData({
result: result
})
})
我在程序中这样写 为什么没反应 ?还是先funcion2执行再function1呀 ?小白求助!
按照你这个写法,你将function1放在function2里调用了,那么就得在适当的地方去调用function2才能有效果。
function1:
function
() {
return
new
Promise(
function
(resolve, reject) {
manager.stop()
resolve();
});
},
function2:
function
() {
let that =
this
;
this
.function1()
.then(
function
(resolve) {
console.log(
"globalData2"
, app.globalData.result);
let result = getApp().globalData.result;
that.setData({
result,
});
});
onLoad() {
this
.function2();
}
非常感谢回复!