手机随时阅读
新人专享大礼包¥24
for...in本身是Object的遍历方法,js中的数组也继承自Object,所以也能够使用for...in遍历出属性。然而for...in遍历数组时有一些细节需要注意。 1、for...in遍历的属性是字符串,而不是数字 const arr = [1, 2, 3] for (const i in
<template> <div class="demo"> <div class="top"> <ul> <li @click="one">回到顶级</li> <li v-for="item of parents" :key="item.value" @click="jump(item)">{{it
const num = 5 try { if (num 5) { throw new Error('num不能为5') } } catch (e) { console.log(e) // 打印出Error对象:Error: num不能为5 console.log(e.message) // 打印:n
销毁组件时,报警告: 解决: utils/hooks.ts export const useFetchState = (...props: any) => { const focus = useRef<any>(null); const [state, setState] = useState(..
function mergePropertyById(arr, property) { const tempIds = [], newArr = [] for (const item of arr) { if (!tempIds.includes(item.id)) { const obj = {
const a = [1, 2, 3, 4, 5, 6, 7, 8] const b = [5, 5, 1, 2] const c = [3, 9] // 判断arr1是否包含arr2 const isInclude = (arr1, arr2) => arr2.every((val) => arr
使用场景: input事件没办法知道我们在使用中文输入法,所以当我们在输入框中编辑中文的时候,按下字母的那一刻就开始触发input事件。 使用compositionstart和compositionend可以对此情况进行优化 需求: 根据用户输入的文字过滤列表选项 实现: <template> <d
一、css不可以继承的属性 display、 margin、padding、border、 background、 width、min-width、max-width、height、min-height、max-height、 overflow、 position、top、bottom、left、r
1、src/directives/preventClick.js import Vue from 'vue' Vue.directive('preventClick', { inserted(el) { el.addEventListener('click', () => { if (!el.dis
一、reduce方法接收2个参数 参数1:function(accumulator, currentValue, index, arr) {},必须 accumulator:必须,初始值(initialValue)或计算后的返回值(上次调用函数的返回值) currentValue:必须,当前元素 i
效果: 所具备的功能: 1、切换学年 2、项目单选 3、前端懒加载(前端分页) 4、打开弹框可以回显上一次选中的项目,点击取消不进行操作 5、通过isRadioChange控制,选中后,再次点击可取消 components/ProjectRadio.vue <template> <div class
效果: 所具备的功能: 1、支持分页,这里是接口支持的分页。推荐:vue基于vant封装上拉加载/下拉刷新组件ListScroller 2、支持搜索,这个也是接口支持的。搜索支持防抖 3、多选(可扩展成支持单选) 4、通过sync修饰符绑定父子组件传参 components/SelectUserPo
效果: 1、数据结构:Calendar/data.js export const data = [ { id: 0, hour: '00:00' }, { id: 1, hour: '01:00' }, { id: 2, hour: '02:00' }, { id: 3, hour: '03:00'
这样会报错 <p :class="today(index)?'active':''">{{date[defaultWeekIndex].date[index]}}</p> computed: { today(index) { const { defaultWeekIndex, date } = th
一、下载依赖cnpm i @fullcalendar/daygrid @fullcalendar/react @fullcalendar/timegrid二、基本使用 Calendar/index.tsximport React, { useEffect, useState } from 'react'import { PageHeaderWrapper } from '@ant-design/
1、components/ConfirmModel/index.tsximport React, { useState, useImperativeHandle } from 'react'import { Modal } from 'antd'import styles from './index.less'import { ExclamationCircleFilled } from '@an
1、css变量的声明 使用--声明变量($被sass用掉了,@被less用掉了) <style> :root { --color: red; } </style> root为根元素,相当于给html设置了css变量 /* :root 相当于 html */ html { --color: red;
问题描述:使用 position: fixed; 设置蒙层后,在安卓上正常,ios上下滑动会造成底层盒子上下滚动 解决方案: 设置当前元素(设置了fixed定位)的父级元素,设置overflow: hidden watch: { // 解决ios遮罩层滚动穿透问题 visible: { handle
box-sizing默认值为 content-box,设置border和padding时会改变width和height 并且不具有继承性,每次设置border或padding时都需要设置一遍box-sizing: border-box;比较麻烦 可以这样设置: html { box-sizing:
在forEach中使用异步函数,会导致执行到await时跳出循环 解决办法: 1、使用for循环 const images: Array<object> = [] for (const { originFileObj } of fileList) { images.push({ src: await
背景:考虑到项目中很多页面都需要图片查看器,每个页面都去引入ImgViewer组件有点麻烦,现在将ImgViewer组件放在公共状态下 1、models/imgViewer.ts import { Reducer } from 'umi' export interface ImgViewerMode
// 判断一个字符串是否是json格式 export const isJson = str => { try { const jsonObj = JSON.parse(str) if ('string' typeof str && 'object' typeof jsonObj) return tr
效果: 预期:像这样的表单结构,如果在form中一行一行写每个文本域,有点麻烦,封装成一个组件,同类型支持新增和删除 ①DynamicForm.vue <template> <div class="dynamic-form"> <div class="title"> <p>{{template.ti
1、仪表盘组件 GaugeChart/index.tsx(组件中的nightFlag是适配黑夜模式,获取公共状态中的值) import React, { useEffect, useRef } from 'react' import styles from './index.less' import
1、ImgViewer/index.tsx import React from 'react' import Viewer from 'react-viewer' interface ImgViewerProps { visible: boolean // 是否显示viewer images: Ar
一、MenuSearch/index.tsx import React, { useState, useEffect } from 'react' import { Select } from 'antd' import { history } from 'umi' import styles fr
诞生背景: 1、DNS:domain name system,域名系统,浏览器请求第三方服务器资源时,必须要将该域名解析为ip地址,浏览器才能发出请求,这个过着叫DNS。DNS实现了域名到ip的映射 2、DNS请求虽然占用了很少的带宽,但会有很高的延迟,尤其在移动端会更加明显。 DNS缓存可以帮助减
main.js import { Toast } from 'vant' window.alert = str => Toast(str) // 全局替换alert 使用场景:如果系统中引入了一些插件,插件中使用的提示是alert,这种方式的提示不友好,可以全局将系统中的alert替换为UI组件库中
Copyright © 2005-2022 51CTO.COM 版权所有 京ICP证060544号