Skip to main content

1-4

1 小程序mock

[1][API Mock](https://developers.weixin.qq.com/miniprogram/dev/devtools/api-mock.html)

2 Ts如何导入一个文件夹内的所有ts文件?

TODO

3 小程序粘性布局

[1][sticky](https://developers.weixin.qq.com/miniprogram/dev/platform-capabilities/extended/component-plus/sticky.html)

4 dayjs常用

获取unix时间

// 毫秒值
dayjs('2019-01-25').valueOf() // 1548381600000
// 秒值
dayjs('2019-01-25').unix() // 1548381600

获取本月时间范围(月初、月末)

// 根据一个时间点获取本月时间范围
export function getRangeMonthMsByOneMs(ms: number) {
const d = dayjs(ms)

return [d.startOf('M').valueOf(), d.endOf('M').valueOf()]
}

5 小程序别名路径

[1][resolveAlias](https://developers.weixin.qq.com/miniprogram/dev/reference/configuration/app.html#resolveAlias)

6 小程序引入动画

[1] https://animate.style/#best-practices

[2][微信小程序开发-76种动画 animate.css](https://developers.weixin.qq.com/community/develop/doc/00024648e982c0819e97ac85c5b804)

[3][wx-wow](https://github.com/Five-great/wx-wow)

7 常用校验

// 银行卡校验,采用LUHN算法(模10算法)
export function verifyBankCard(num: string) {
let numArr = num.toString().split('') //变为字符串再转数组
if (numArr.length > 19 || numArr.length < 15) return false //银行卡号长度为15-19
let lastNum = parseInt(numArr[numArr.length - 1]) //取出最后一位--校验位
numArr.length = numArr.length - 1 //删除最后一个值
numArr = numArr.reverse() //变为数组再颠倒

let sum = 0 //总数
numArr.forEach((elem, i) => {
let elemInt = parseInt(elem)
if (i % 2 === 0) {
let n = elemInt * 2
if (n < 10) sum += n
else sum += Math.floor(n / 10) + (n % 10)
} else sum += elemInt
})
return (sum + lastNum) % 10 === 0 ? true : false
}
// 是否为空字符
export function verifyIsEmpty(str: string) {
str = str.trim()
return str.length === 0
}

微信小程序表单验证

we-validator

8 数据模型关系

一对一、一对多、对对多

[1] https://typegoose.github.io/typegoose/docs/guides/advanced/reference-other-classes/#common-problems

[2][2 way ref return ref null or undefined](https://github.com/typegoose/typegoose/issues/681)

9 CRON 表达式详解

[1][CRON 表达式详解](https://help.aliyun.com/document_detail/133509.html)

10 小程序固定列

[1][微信小程序实现固定表头固定列表格](https://juejin.cn/post/6965789342195253284)

11 微信小程序swiper组件小圆点样式更改

[1][微信小程序swiper组件小圆点样式更改](https://www.jianshu.com/p/b0dbcf7360ad)

12 png to base64

https://www.atatus.com/tools/png-to-base64