合规国际互联网加速 OSASE为企业客户提供高速稳定SD-WAN国际加速解决方案。 广告
>通过window.MutationObserver对象实现简单的nextTick function nextTick(callback,ctx){ let counter = 0 let textNode = document.createTextNode(String(counter)); let fn = ctx ? callback.bind(ctx) : callback; let watcher = new window.MutationObserver(fn); let options ={ characterData : true } watcher.observe(textNode,options) counter++; textNode.data = String(counter) }; //--测试 let name = 'dufu' let person = { name : 'libai', show(){ console.log(this.name) } }; nextTick(person.show,person); console.log('1');