随笔分类 - JavaScript
摘要:initCheckLongTime() { // 计算年月 let birthYear = this.prpLpayPerson.identifyNumber ? this.prpLpayPerson.identifyNumber.substring(6, 10) : ""; console.log
阅读全文
摘要:function semicolon_Add(num){ num = num.replace(/,/g,""); if (num != ""){ var re = /^\d+(\.\d+)?$/; if(re.test(num)){ var parts = num.toString().split(
阅读全文
摘要:/** * 保留小数点n位且整数自动补零 * */ pointFloor(num, n) { if (typeof(num) == 'number' || typeof(num) == 'string') { let numStr = num + ""; let list = numStr.spli
阅读全文
摘要:let arr = []; if (res.data && res.data.havePowerComCodes) { for (const [key, value] of Object.entries(res.data.havePowerComCodes)) { const obj = { lab
阅读全文
摘要:this.type = this.issuspected == 1 ? 0 : 1; this.issuspected == 1 ? this.type=0 : this.type=1 以上两个等同。。
阅读全文
摘要:对象解构: https://www.jianshu.com/p/fed61b907ab5 数组解构: https://www.jianshu.com/p/a8f74b29d0d1
阅读全文
摘要:map和forEach都用于遍历数组,forEach没有返回值。map返回值是新的数组。 <script> let arr = [ {title:'aaa',read:50}, {title:'bbb',read:50}, {title:'ccc',read:50} ]; let newArr =
阅读全文
摘要:/** * 存储localStorage */ export const setStorage = (name, content) => { if (!name) return; if (typeof content !== 'string') { content = JSON.stringify(
阅读全文
摘要:两种方法: 1、使用正则 function getQueryString(name) { //取url上的id var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i"); var r = window.location.search.su
阅读全文
摘要:类似于elementUI 的 el-autocomplete远程搜索 参考:https://github.com/Daotin/fe-notes/issues/170 1 <template> 2 <div id="app"> 3 <!-- <input type="text" :value="fi
阅读全文
摘要:一、原生js的监听 addEventListener()与removeEventListener() 参考文章:https://blog.csdn.net/qq_29606781/article/details/67650869、https://www.cnblogs.com/wxcbg/p/104
阅读全文
摘要:1.html代码: 2.js代码: //可视区域的宽(视口宽-图片所占的宽度)screenWidth=document.documentElement.clientWidth;imgWidth=162;/*imgobj.clientWidth*/diffWidth=screenWidth-imgWi
阅读全文