Skip to Content
React学习手册
book

React学习手册

by Alex Banks, Eve Porcello
December 2017
Intermediate to advanced
329 pages
6h 9m
Chinese
China Electric Power Press Ltd.
Content preview from React学习手册
28
2
getFakeMembers(5).then(
members => console.log(members),
err => console.error(
new Error("cannot load members from randomuser.me"))
)
Promise
对象处理异步请求的方法更容易,效果也更好,因为我们在
JavaScript
中必须
处理大量的异步数据。读者还会发现在
Node.js
Promise
对象的身影随处可见,因此
深刻理解
Promise
对象对于当前的
JavaScript
工程师来说至关重要。
在以前的
JavaScript
中,官方规范中并没有类的概念。类型定义是通过函数完成的。
我们创建了一个函数,然后通过原型(
prototype
)在函数对象上定义方法:
function Vacation(destination, length) {
this.destination = destination
this.length = length
}
Vacation.prototype.print = function() {
console.log(this.destination + " | " + this.length + " days")
}
var maui = new Vacation("Maui", 7);
maui.print(); // Maui | 7
如果读者以前使用的是经典的面向对象程序设计方法进行开发的,那么这一点可能会 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

React快速上手开发

React快速上手开发

Stoyan Stefanov
流畅的Python

流畅的Python

Luciano Ramalho
C++语言导学(原书第2版)

C++语言导学(原书第2版)

本贾尼 斯特劳斯特鲁普

Publisher Resources

ISBN: 9787519814236