testThen() {
const that = this;
if (that.num < that.qualitySelect.length) {
that.testPromise(that.num).then(function (data) {
that.num++;
that.testThen(that.num);
});
} else {
that.num = 0;
that.testThen();
}
},
testPromise(i) {
const that = this;
return new Promise(function (resolve, reject) {
setTimeout(function () {
that.qualityType = that.qualitySelect[i];
resolve();
}, 10000);
});
},
num:0,
qualitySelect:[0,1,2,3,4,5,6],
qualityType:""
每十秒qualityType 值更换一次,更换完后重新开始循环。
默认调取testThen();