随笔分类 - js
运用js
摘要:1. 获取服务器目录信息 //getOssXXXX 获取服务器目录信息Api//fileType 文件类格式//ossAuthority 文件属性 1公开 2 私有 const policyResult: any = await getOssXXXX({ fileType: 'png', ossAu
阅读全文
摘要:正则判断 // 身份证校验 export function checkIdCard(value: string) { console.log('checkIdCard', value); if (!value) return false; const ID = value.toUpperCase()
阅读全文
摘要:设置meta标签属性 <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, viewport-fit=cover" /> 这个viewpor
阅读全文
摘要:CSS 自定义属性 tsx文件定义属性 import React from 'react'; import './Component.scss'; const MyComponent: React.FC = () => { const primaryColor = '#3498db'; const
阅读全文
摘要:第一步:基础view import { View as TaroView } from '@tarojs/components'; import { ViewProps } from '@tarojs/components/types/View'; import dayjs from 'dayjs'
阅读全文
摘要:import { useCallback, useEffect, useRef } from 'react'; export interface DebounceRefType { fn: Function; timer?: NodeJS.Timeout; } export type Debounc
阅读全文
摘要:方法: const imgSrcQueue: Array<HTMLImageElement> = []; export function preloadImageList(names) { return new Promise((resolve) => { let n = 0, img, imgs
阅读全文
摘要:封装一个可以使用onAppear的<VIew/>组件: import React, { PureComponent } from 'react'; class View extends PureComponent { constructor(props) { super(props); this.t
阅读全文
摘要:适用范围:支付宝,淘宝小程序 效果: 组件目录结构: 详情: index.axml <!-- [{"value":["3","5"],"style":"","isTime":true},{"value":"秒","style":""}] --> <view class="countdown-main
阅读全文
摘要:获取一个特定时间的时间戳,我们的选择有很多,dayjs,moment等,但常规的,我们一般用 new Date()来获取; 比如: 但在ios环境下,以上运行获取的为:NaN; 只有将‘-’改为‘/’才能正确获取其对应时间戳。 如 new Date('2023/03/10 23:59:59').ge
阅读全文
摘要:上代码: <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" conten
阅读全文
摘要:骨骼动画 首先我们想要了解骨骼动画的写法,就得去了解Tiyjs。骨骼动画是基于tinyjs平台二次开发的插件运用。 官网地址: http://tinyjs.net/guide/ 插件种类: 在官网插件平台上,我们似乎可以找到三个有关骨骼动画的插件平台。spine,creature,dragonbon
阅读全文
摘要:场景:比如我们在进行一些图片分享链接时,要进行一些特定连接的字符串拼接。这个时候就需要对我们的链接进行 uri编码操作。比如:百度地址:https://www.baidu.com方法:encodeURIComponent("https://www.baidu.com") //我们可以通过原生的 en
阅读全文
摘要:async function imageToData64(Url) { //传任意一图片地址 return new Promise((resolve, reject) => { let image = new Image(); image.src = itemUrl; image.crossOrig
阅读全文
摘要://防止连点 const canHamdle = useRef(true); function onHandleSubmit() { if (!canHamdle.current) { return } else { fun something(); canHamdle.current = fals
阅读全文
摘要:dayjs('2021-10-19').diff('2021-11-18', 'day'))
阅读全文
摘要:import { createElement, useEffect, useState } from 'rax'; import View from 'rax-view'; import classnames from 'classnames'; import { isValidNumber } f
阅读全文
摘要:淘宝参考:http://h5.alibaba-inc.com/api/WindVane-API.html 支付宝参考:https://smallfish.antfin-inc.com/alipayjsapi/ap.chooseImage.html#option-%E5%8F%82%E6%95%B0%
阅读全文
摘要:处理逻辑,经常需要在dom重现使用时回掉函数(重新请求数据,重新定义状态等),以下是工作中常用的一个重新回掉函数的定义: import { useEffect } from "react"; export default function useResume(fn: any, deps: Array
阅读全文
摘要:function ViewMore({ hasMore, request, cursor, list }) { function handleOnAppear() { if (!hasMore) { return; } request(cursor); } return ( <View classN
阅读全文

浙公网安备 33010602011771号