jQuery deferred.resolveWith() 方法

jQuery 教程 · 2019-03-29 23:18:26

定义和用法

deferred.resolveWith() 函数用于解决Deferred(延迟)对象,并根据给定的 context 和 args 参数调用任何 doneCallbacks 回调函数。


注意:1. 通常只有延迟对象的创建者才可以调用该方法。你可以通过调用 deferred.promise(),返回一个受限的 Promise 对象,来阻止其它代码改变延迟对象的状态或报告它的状态。
2. 当延迟对象被 resolved 时,任何通过 deferred.then 或 deferred.done 添加的 doneCallbacks,都会被调用。回调函数按它们被添加时的顺序执行。传递给 deferred.resolve() 的 args 参数, 会传给每个回调函数。当延迟对象进入 resolved 状态后,任何 doneCallbacks 被添加时,就会被立刻执行,并带上传入给 .resolve() 的参数。

语法

deferred.resolveWith( context [, args ] )

参数 描述
context Object类型 作为 this对象传递给 doneCallbacks 回调函数
args Array类型 传递一个可选的参数数组给 oneCallbacks 回调函数

点击查看所有 jQuery 教程 文章: https://www.codercto.com/courses/l/35.html

查看所有标签

Web Development Recipes

Web Development Recipes

Brian P. Hogan、Chris Warren、Mike Weber、Chris Johnson、Aaron Godin / Pragmatic Bookshelf / 2012-1-22 / USD 35.00

You'll see a full spectrum of cutting-edge web development techniques, from UI and eye candy recipes to solutions for data analysis, testing, and web hosting. Make buttons and content stand out with s......一起来看看 《Web Development Recipes》 这本书的介绍吧!

URL 编码/解码
URL 编码/解码

URL 编码/解码

Markdown 在线编辑器
Markdown 在线编辑器

Markdown 在线编辑器

RGB CMYK 转换工具
RGB CMYK 转换工具

RGB CMYK 互转工具