随笔分类 - js
摘要:<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Document<
阅读全文
摘要:/** * 根据不同时区显示时间 * @param time * @returns {*} */ export function getLocalTime(time) { if (typeof time !== 'number') return; let d = new Date(); let of
阅读全文
摘要:Intl.DateTimeFormat().resolvedOptions().timeZone
阅读全文
摘要:<input type="text" v-model="amount" oninput="value=value.replace(/[^0-9.]/g,'')" placeholder="enter amount">
阅读全文
摘要:在assets下新建tool.js文件 function countDownFun(time) { time--; let nowTime = new Date().getTime(); // 获取当前时间 if (time >= nowTime) { var secondTime = 0 //秒
阅读全文
摘要:export function browserRedirect() { var sUserAgent = navigator.userAgent.toLowerCase(); var bIsIpad = sUserAgent.match(/ipad/i) == "ipad"; var bIsIpho
阅读全文
摘要:首先我们先认识一下常见个进制:在js中,如果要表示一个16进制的数字,则以 0x 开头如果是8进制的数字,则以 0 开头如果是2进制的数字,则以 0b 开头 举例: 16进制 0xff , 0x66 ..... 8进制 040 , 035 ..... 2进制 0b10 , 0b11 ..... 在j
阅读全文
摘要:data(){ return{ data1: [] } }, created() { this.dsdd(7) }, methods:{ getDay(day) { var today = new Date(); var targetday_milliseconds = today.getTime(
阅读全文
摘要:第一种: 第二种: 正则匹配 let a = 'https://cnblogs.com/posts/edit' let b = /^http(s)?:\/\/(.*?)\//console.log(b.exec(a)[2])// cnblogs.com
阅读全文
摘要:document.querySelector(`#id`).scrollIntoView()
阅读全文
摘要:fun_date(num) { var date1 = new Date();var date2 = new Date(date1); date2.setDate(date1.getDate() + num); //num是正数表示之后的时间,num负数表示之前的时间,0表示今天 var time2
阅读全文
摘要:首先先安装模块工具 cnpm install clipboard --save 在当前页面引入模块 import Clipboard from 'clipboard'; 使用:html代码 <div class="box">我的邀请码:<span class="inviteCode" >XF684V
阅读全文
摘要:countdown(){ // 目标时间 let newdate = new Date('2021-04-21 11:40:00') let setINT = setInterval(() => { // 当前时间 let olddate = new Date() // 目标时间减去当前时间 let
阅读全文
摘要:data = [ {id:1,name:'张三'}, {id:2,name:'李四'}, {id:3,name:'王五'} ] let item = 2 // 使用find方法根据id查询对应对象 let a = data.find((ele)=>{ return ele.id == item })
阅读全文
摘要:data = [ {id:1,name:'a'}, {id:3,name:'b'}, {id:3,name:'c'}, {id:2,name:'a'} ] // 根据id去重 var arr1=data.filter(function(element,index,self){ return self
阅读全文
摘要:var str = '<p>领先文<em>化·狼性长</em>程<strong>的人和事。人</strong><u>情练达即</u></p>' //举个例子:下面是清除p标签 str = str.replace(/<\/?p[^>]*>/gi,'') console.log(str) //领先文<e
阅读全文
摘要:清除标签中的class属性 str = 'xxxxxxxxxxxxxxxxxxxxxxxx'str = str.replace(/class\s*?=\s*?([‘"])[\s\S]*?\1/, "");
阅读全文
摘要:清除标签中的style属性,不让自带默认属性 str = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'str = str.replace(/style\s*?=\s*?([‘"])[\s\S]*?\1/, ""); // 清除指定标签中的class属性 var str = '<
阅读全文
摘要:清除富文本中所有   这些空格字符 html = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'html.replace(/ /g,"").replace(/ /g,"").replace(/ /g,"")
阅读全文

浙公网安备 33010602011771号