我在下面使用了这两个来源:
但它们都不在extjs版本6中有效
每当有新操作开始时,如何取消加载操作?
在ExtJS版本6.0.2中,某些事情已更改,并且Operation
类具有和abort
方法
没有getOperation方法,但是有个方法beforeload
对抓取操作很有用。
通过收集一个或多个操作,您可以abort
在开始新操作之前安全地进行操作。
以下Typescript类将有所帮助:
module ext_ts {
interface Abortable {
abort(): void
}
export class AutoAbortPreviousOperation {
private _storeOperations: Array<Abortable> = []
applyOnStore(store): any {
let me = this
return store.on({
destroyable: true,
beforeload: function (theStore, operation, eOpts) {
let lastOperation = me._storeOperations.pop()
if (lastOperation) {
console.log("aborting previous operation safely")
lastOperation.abort() //this abort is safe so no need to check !lastOperation.isComplete()
} else {
//nop
}
me._storeOperations.push(operation) //add this operation for later usage
return true //let the loading begin
}
})
}
}
}
请注意,statusCode
被用户强行取消的请求的值为:-1
有用的链接:
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句