02 2022 档案
摘要:什么是装饰器 装饰器是一种特殊的声明,可以附加到类声明、方法、访问器、属性或参数。 装饰器必须使用 @expression 方式使用,expression 必须是一个函数。 开启装饰器 // tsconfig.json: { "compilerOptions": { "target": "ES5",
阅读全文
摘要:const inquirer = require('inquirer'); const chalk = require('chalk'); const DEFAULT_TEMPLATE_SRC = 'github:NervJS/taro-project-templates#v3.1' const D
阅读全文
摘要:支持限制并发数 class PromiseQueue { limit: number active: number queue: Array<() => Promise<any>> constructor(limit = 3) { // 并发限制 this.limit = limit; // 当前活
阅读全文
摘要:@tarojs/taro import Taro, { useDidShow } from '@tarojs/taro' 我们用的最频繁的包就是 @tarojs/taro // taro/index.js const { CurrentReconciler } = require('@tarojs/
阅读全文
摘要:chunk 将数组(array)拆分成多个 size 长度的区块,并将这些区块组成一个新数组。 如果array 无法被分割成全部等长的区块,那么最后剩余的元素将组成一个区块。 let newArray = chunk(array, 2); //将 array 分成两组 原理 var index =
阅读全文
摘要:通过阅读 Taro 源码后可以知道,Taro 是在@tarojs/mini-runner/dist/index.js 文件中,调用了 webpack 进行打包。 export default async function build (appPath: string, config: IBuildC
阅读全文
摘要:/** * 将 async/await 转为 generator 以 Promise 形式使用,可以在过程中随时打断/等待 * function build(appPath, config) { return awaiter(this, undefined, undefined, function*
阅读全文
摘要:forEach forEach,对数组的每个元素执行一次给定的函数。 const array1 = ['a', 'b', 'c']; array1.forEach(element => console.log(element)); fill、map file,用一个固定值填充一个数组中从起始索引到终
阅读全文
摘要:taro-plugin-skeleton 配合index.config使用 单独写骨架屏页面,与原有业务耦合度较低。 当页面渲染固定元素,骨架屏会被遮挡 原理:拦截原有小程序底层页面,使用骨架屏页面替换。 当小程序View 没有渲染的时候展示骨架屏,小程序View展示会遮挡住骨架屏页面。 缺点: 上
阅读全文
摘要:1.Types 类型 & Coercion 类型转换 Primitive Types 原始类型 underfined string number boolean object symbol null 其中 null,虽然是基本变量,但是因为设计的时候null是全 0,而object是 000 开头,
阅读全文