async created() { // Promise.all([this.getTodos(), this.getComments(), this.getAlbums()]).then( // (res) => { // console.log(res) // } // ) const data
import axios from 'axios' export default { mounted() { // this.getTodos().then((res) => { // console.log('todos', res.data) // this.getComments().then
<script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.6.0/jquery.js"></script> <script> const ID_BASE_URL = 'https://jsonplaceholder.typicode.com/to
结论: 1、then 正常返回时,Promise的状态为fulfilled 报错时,Promise的状态为rejected 2、catch 正常返回时,Promise的状态为fullfilled 报错时,Promise的状态为rejected 当状态为成功时: const p = Promise.r
一、async函数返回值都是Promise对象 二、promise.then 成功的情况 对应await 三、promise.catch 失败的情况 对应try…catch 一、async函数返回值都是Promise对象 1、返回值不是promise对象,那么新promise的状态为fullfill
class Person { constructor(name) { this.name = name } publicFn() { console.log('公共方法') } } class Student extends Person { constructor(name, score) { /
1、方法一:定义临时变量 2、方法二:利用数组的解构(不需要第三个变量)
Copyright © 2005-2025 51CTO.COM 版权所有 京ICP证060544号