会员
众包
新闻
博问
闪存
赞助商
HarmonyOS
Chat2DB
所有博客
当前博客
我的博客
我的园子
账号设置
会员中心
简洁模式
...
退出登录
注册
登录
波西米亚
博客园
首页
新随笔
联系
管理
随笔分类 -
JavaScript
javascript
JS时间操作
摘要:// 获取下个月的特定一天 getSpecificDayOfNextMonth(day, dayEnd = 0) { let now = new Date(); now.setMonth(now.getMonth() + 1, day); // 设置月份加一,日期设置为特定的一天 if (dayEn
阅读全文
posted @
2024-12-07 16:33
东风-5C(全球可飞)
阅读(34)
评论(0)
推荐(0)
JS 树型结构数据简易递归
摘要:js树型结构数据简易递归 // item内的值根据实际情况更换replaceValueInTree (tree) { const result = [] tree.forEach((item) => { let children = item.children || [] if (Array.isA
阅读全文
posted @
2024-10-17 17:19
东风-5C(全球可飞)
阅读(65)
评论(0)
推荐(0)
JS trim方法改造
摘要:// 去除字符串两边的指定字符function strTrim(string, char, type) { if (char) { if (type 'left') { return string.replace(new RegExp('^\\' + char + '+', 'g'), ''); }
阅读全文
posted @
2024-07-23 14:52
东风-5C(全球可飞)
阅读(12)
评论(0)
推荐(0)
JS substr 根据字节长度截取字符串
摘要:js substr 根据字节长度截取字符串此方法应该还可以被优化一下 /** * 根据字节长度截取字符串 * @param str 字符串 * @param bytesStart 字节截取起始位置 * @param bytesLen 字节截取长度 */substrByBytes(str, bytes
阅读全文
posted @
2024-03-21 13:49
东风-5C(全球可飞)
阅读(135)
评论(0)
推荐(0)
HTML 阻止浏览器自动填充input密码框
摘要:方法1:把input的 type="password" 改成 type="text" 并在后面加上 οnfοcus="this.type='password'" <input type="text" placeholder="密码" onfocus="this.type='password'"/>
阅读全文
posted @
2024-02-23 15:34
东风-5C(全球可飞)
阅读(758)
评论(0)
推荐(0)
JS中几种追加元素的方法
摘要:a:要追加的位置 b:要追加的内容 1、append:a.append(b) 将b追加到a的内部的末尾,b是a的子元素 2、appendTo:b.appendTo(a) 将b追加到a的内部的末尾,b是a的子元素 3、prepend:a.prepend(b),将b追加到a的内部的最前面,b是a的子元素
阅读全文
posted @
2024-02-20 11:18
东风-5C(全球可飞)
阅读(1118)
评论(0)
推荐(0)
JS 数字字符串补零
摘要:有时为了格式美观,我们需要给数字统一格式,比如001,002,003,这就有了为数字补足0的需求。具体见代码 // num: 数字 // fill: 补足后的位数 padNumber(num, fill) { let len = ('' + num).length; if (fill > len)
阅读全文
posted @
2024-01-22 16:27
东风-5C(全球可飞)
阅读(1097)
评论(0)
推荐(1)
HTML 移动端禁止浏览器强制缩放
摘要:移动端H5页面加上 <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0"> 还是会被浏览器强制缩放。
阅读全文
posted @
2023-12-21 16:04
东风-5C(全球可飞)
阅读(275)
评论(0)
推荐(0)
判断是否是json字符串
摘要:const isJson = str => { try { JSON.parse(str); return true; } catch (e) { return false; } }; isJson('{"name":"小明","address":"苏州"}'); // true isJson('{
阅读全文
posted @
2023-11-25 08:28
东风-5C(全球可飞)
阅读(77)
评论(0)
推荐(0)
Vue每次切换路由时滚动到页面顶部
摘要:vue3配置跳转到新的路由界面的位置 import { createRouter, createWebHashHistory } from 'vue-router' // vue2.0 new VueRouter({}) 创建路由实例 // vue3.0 creatRouter({}) 创建路由实例
阅读全文
posted @
2022-06-10 22:52
东风-5C(全球可飞)
阅读(531)
评论(0)
推荐(0)
JS async函数
摘要:一,async函数介绍 1.async函数是异步的一种方案,可以让异步的操作同步执行。 二,async函数基本形式 1.声明形式:在函数前加上关键字async 表示该函数是一个async 函数 async function fn(){ await ... } const fn = async ()=
阅读全文
posted @
2022-05-28 09:01
东风-5C(全球可飞)
阅读(285)
评论(0)
推荐(0)
封装axios
摘要:封装axios一、创建文件utils/request.js // 基于 axios 封装的请求模块 import axios from 'axios' // 新建一个新的axios实例 const newAxios = axios.create({//创建返回一个新的axios函数对象 baseUR
阅读全文
posted @
2022-05-26 11:03
东风-5C(全球可飞)
阅读(106)
评论(0)
推荐(0)
JS获取键盘事件
摘要:JS 键盘
阅读全文
posted @
2018-10-23 11:16
东风-5C(全球可飞)
阅读(16471)
评论(0)
推荐(0)
JS正则表达式检验数字或者带小数点的数字
摘要:1. var patrn = /^\d+(\.\d+)?$/; var num = 0.11; if (!patrn.exec(num)){ alert("请您输入数字");return; }2. var patten = /^[+-]?(0|([1-9]\d*))(\.\d+)?$/g; var
阅读全文
posted @
2018-09-29 16:31
东风-5C(全球可飞)
阅读(29226)
评论(0)
推荐(1)
公告