摘要: const inquirer = require('inquirer'); const chalk = require('chalk'); const DEFAULT_TEMPLATE_SRC = 'github:NervJS/taro-project-templates#v3.1' const D 阅读全文
posted @ 2022-02-24 15:12 远方的少年🐬 阅读(93) 评论(0) 推荐(0) 编辑
摘要: 支持限制并发数 class PromiseQueue { limit: number active: number queue: Array<() => Promise<any>> constructor(limit = 3) { // 并发限制 this.limit = limit; // 当前活 阅读全文
posted @ 2022-02-21 15:45 远方的少年🐬 阅读(80) 评论(0) 推荐(0) 编辑
摘要: @tarojs/taro import Taro, { useDidShow } from '@tarojs/taro' 我们用的最频繁的包就是 @tarojs/taro // taro/index.js const { CurrentReconciler } = require('@tarojs/ 阅读全文
posted @ 2022-02-18 18:15 远方的少年🐬 阅读(258) 评论(0) 推荐(0) 编辑
摘要: chunk 将数组(array)拆分成多个 size 长度的区块,并将这些区块组成一个新数组。 如果array 无法被分割成全部等长的区块,那么最后剩余的元素将组成一个区块。 let newArray = chunk(array, 2); //将 array 分成两组 原理 var index = 阅读全文
posted @ 2022-02-18 10:10 远方的少年🐬 阅读(121) 评论(0) 推荐(0) 编辑
摘要: 通过阅读 Taro 源码后可以知道,Taro 是在@tarojs/mini-runner/dist/index.js 文件中,调用了 webpack 进行打包。 export default async function build (appPath: string, config: IBuildC 阅读全文
posted @ 2022-02-16 11:32 远方的少年🐬 阅读(1417) 评论(0) 推荐(0) 编辑
摘要: /** * 将 async/await 转为 generator 以 Promise 形式使用,可以在过程中随时打断/等待 * function build(appPath, config) { return awaiter(this, undefined, undefined, function* 阅读全文
posted @ 2022-02-16 09:44 远方的少年🐬 阅读(65) 评论(0) 推荐(0) 编辑
摘要: forEach forEach,对数组的每个元素执行一次给定的函数。 const array1 = ['a', 'b', 'c']; array1.forEach(element => console.log(element)); fill、map file,用一个固定值填充一个数组中从起始索引到终 阅读全文
posted @ 2022-02-15 17:01 远方的少年🐬 阅读(88) 评论(0) 推荐(0) 编辑
摘要: 1.Types 类型 & Coercion 类型转换 Primitive Types 原始类型 underfined string number boolean object symbol null 其中 null,虽然是基本变量,但是因为设计的时候null是全 0,而object是 000 开头, 阅读全文
posted @ 2022-02-07 17:20 远方的少年🐬 阅读(28) 评论(0) 推荐(0) 编辑
摘要: 联合类型 interface Bird { name: string; fly(): void; } interface Person { name: string; talk(): void; } type BirdPerson = Bird | Person; let p: BirdPerson 阅读全文
posted @ 2022-01-21 16:58 远方的少年🐬 阅读(43) 评论(0) 推荐(0) 编辑
摘要: ES6 规范中,引入了 class 的概念。 但是 JS 中并没有一个真正的 class 原始类型, class 仅仅只是对原型对象运用语法糖。 函数声明和类声明之间的一个重要区别在于, 函数声明会提升,类声明不会。 class Cat{ constructor(name,age){ this.na 阅读全文
posted @ 2022-01-21 15:55 远方的少年🐬 阅读(43) 评论(0) 推荐(0) 编辑