04 2021 档案
摘要:const musicBack = wx.getBackgroundAudioManager();Page({ data: { }, backmusic(url=''){ musicBack .title = "此时此刻"; musicBack .src = "http://gn.sycdn.kuw
阅读全文
摘要:display:flex 是一种布局方式。它即可以应用于容器中,也可以应用于行内元素。是W3C提出的一种新的方案,可以简便、完整、响应式地实现各种页面布局。目前,它已经得到了所有浏览器的支持。 Flex是Flexible Box的缩写,意为"弹性布局",用来为盒状模型提供最大的灵活性。设为Flex布
阅读全文
摘要:css3 text-shadow字体阴影讲解 text-shadow:为字体添加阴影, 可以通过对text-shadow属性设置相关的属性值,来实现现一些需要的字体阴影效果,减少了图片的使用。 基础说明: text-shadow: X轴 Y轴 Rpx color; 属性说明(顺序依次对应): 阴影的
阅读全文
摘要:import export 这两个家伙对应的就是es6自己的module功能。 我们之前写的Javascript一直都没有模块化的体系,无法将一个庞大的js工程拆分成一个个功能相对独立但相互依赖的小工程,再用一种简单的方法把这些小工程连接在一起。 这有可能导致两个问题: 一方面js代码变得很臃肿,难
阅读全文
摘要:ECMAScript 6(以下简称ES6)是JavaScript语言的下一代标准。 最常用的ES6特性 let, const, class, extends, super, arrow functions, template string, destructuring, default, rest
阅读全文
摘要:第一种方式: text-align:center; vertical-align:middle; div{ text-align: center; vertical-align:middle;width: 400px; height: 400px; border: 1px solid #000; }
阅读全文
摘要:241.返回数组中第 n 个元素(支持负数) 方案一:slice function nthElement(arr, n = 0) { return (n >= 0 ? arr.slice(n, n + 1) : arr.slice(n))[0]; } nthElement([1,2,3,4,5],
阅读全文
摘要:11.判断是否为数字 /** * @description 判断是否为数字 * @param value * @returns {boolean} */ export function isNumber(value) { const reg = /^[0-9]*$/; return reg.test
阅读全文
摘要:181.如何在等待指定时间后调用提供的函数? const delay = (fn, wait, ...args) => setTimeout(fn, wait, ...args); delay( function(text) { console.log(text); }, 1000, 'later'
阅读全文
摘要:151.数组中某元素出现的次数 /** * @param { array } arr * @param {*} value */ export function countOccurrences(arr, value) { return arr.reduce((a, v) => v value ?
阅读全文
摘要:121.cookie 获取 /** * @param {String} key 属性 */ export const cookieGet = (key) => { const cookieStr = unescape(document.cookie); const arr = cookieStr.s
阅读全文
摘要:91.返回当前url export const currentURL = () => window.location.href; 92.获取url参数(第一种) /** * @param {*} name * @param {*} origin */ export function getUrlPa
阅读全文
摘要:61.验证linux"文件"路径 /** @param { string } value */ export const isLinuxFilePath = value => /^(\/[^/]+)+$/g.test(value); 62.验证window"文件夹"路径 /** @param { s
阅读全文
摘要:31.从对象中选取对应于给定键的键值对 // pick: 从对象中选取对应于给定键的键值对 // 使用Array.reduce()将筛选/选取的密钥转换回具有相应键值对的对象 (如果在 obj 中存在该键)。 let pick = (obj, arr) => arr.reduce((acc, cur
阅读全文
摘要:1.匹配正整数 // 匹配正整数 let isPositiveNum = val => { return /^[1-9]d*$/.test(val); }; console.log(isPositiveNum(9)) //true console.log(isPositiveNum(2.2)) //
阅读全文
摘要:为元素添加on方法 Element.prototype.on = Element.prototype.addEventListener; NodeList.prototype.on = function (event, fn) {、 []['forEach'].call(this, function
阅读全文
摘要:function getDuration(value,dateFormat){ let hour = parseInt((value) / 3600); if (hour<10) {//时 hour = "0" + hour; } var minute = parseInt((value % 360
阅读全文
摘要:只允许输入数字(整数:小数点不能输入)<input type="text" onkeyup="value=value.replace(/[^\d]/g,'')" > 允许输入小数(两位小数)<input type="text" onkeyup="value=value.replace(/^\D*(\
阅读全文

浙公网安备 33010602011771号