随笔分类 -  JavaScript

JavaScript
摘要:document.querySelector('a').onclick = (event) => { event = event || window.event event.preventDefault(); event.returnValue = false; } 阅读全文
posted @ 2023-04-24 15:33 Action_swt 阅读(14) 评论(0) 推荐(0) 编辑
摘要:IOS默认播放大屏播放,安卓播放可以同时播放多个,因为IOS默认是大屏播放所以不存在同时播放多个视频的现象。需求1、安卓一次播放一个视频,播放一个其中一个停止播放。 const videoList = document.getElementsByTagName("video"); const vid 阅读全文
posted @ 2022-10-19 13:59 Action_swt 阅读(308) 评论(0) 推荐(0) 编辑
摘要:function dispatchEventStroage () { const signSetItem = localStorage.setItem; localStorage.setItem = function (key, val) { let setEvent = new Event('se 阅读全文
posted @ 2022-09-23 10:56 Action_swt 阅读(35) 评论(0) 推荐(0) 编辑
摘要://防止页面后退 history.pushState(null, null, document.URL); window.addEventListener('popstate', function () { history.pushState(null, null, document.URL); } 阅读全文
posted @ 2022-06-30 15:36 Action_swt 阅读(712) 评论(0) 推荐(0) 编辑
摘要: 阅读全文
posted @ 2022-04-07 22:52 Action_swt 阅读(14) 评论(0) 推荐(0) 编辑
摘要:const beforeUpload = file => { var reader = new FileReader(); reader.readAsDataURL(file); //转化二进制流,异步方法 reader.onload = function(){ //完成后this.result为二 阅读全文
posted @ 2022-04-07 16:34 Action_swt 阅读(3303) 评论(0) 推荐(0) 编辑
摘要:Blob 对象表示一个不可变、原始数据的类文件对象。它的数据可以按文本或二进制的格式进行读取,也可以转换成 ReadableStream 来用于数据操作。 前端展示原始文件有两种方式: 1、将接口直接写到 src 里面(比如 img 的src) > 不方便拿接口头字段信息。 2、转换为URL对象。 阅读全文
posted @ 2022-03-18 10:26 Action_swt 阅读(801) 评论(0) 推荐(0) 编辑
摘要://方式1:const copyText = (text, callback) => { // text: 要复制的内容, callback: 回调 var tag = document.createElement('input'); tag.setAttribute('id', 'copy_inp 阅读全文
posted @ 2022-01-04 16:20 Action_swt 阅读(177) 评论(0) 推荐(0) 编辑
摘要:!(function (doc, win) { // 拿到html标签的dom元素对象 var docEle = doc.documentElement, evt = "onorientationchange" in window ? "orientationchange" : "resize", 阅读全文
posted @ 2021-12-21 19:19 Action_swt 阅读(287) 评论(0) 推荐(0) 编辑
摘要:/** * 解决两个数相加精度丢失问题 * @param a * @param b * @returns {Number} */ function floatAdd(a, b) { var c, d, e; if(undefined==a||null==a||""==a||isNaN(a)){a=0 阅读全文
posted @ 2021-07-22 15:02 Action_swt 阅读(37) 评论(0) 推荐(0) 编辑
摘要:$(function(){ jQuery(document).ready(function () { if (window.history && window.history.pushState) { $(window).on('popstate', function () { /*当点击浏览器的 阅读全文
posted @ 2020-12-07 17:38 Action_swt 阅读(31) 评论(0) 推荐(0) 编辑
摘要:function getCookieByString(cookieName){ var start = document.cookie.indexOf(cookieName+'='); if (start == -1) return false; start = start+cookieName.l 阅读全文
posted @ 2020-10-14 16:04 Action_swt 阅读(121) 评论(0) 推荐(0) 编辑
摘要://获取本地ip function getIPAdress() { var interfaces = require('os').networkInterfaces(); for (var devName in interfaces) { var iface = interfaces[devName 阅读全文
posted @ 2020-09-17 10:52 Action_swt 阅读(5730) 评论(0) 推荐(0) 编辑
摘要:https://blog.csdn.net/ixygj197875/article/details/79090578 阅读全文
posted @ 2020-08-13 14:51 Action_swt 阅读(174) 评论(0) 推荐(0) 编辑
摘要:解决方法: 1、回调 (利用函数回调将返回值带出去。) 2、 利用promise 3、async解决方式。 常用的就是这三种,还可以利用 generator 解决问题。 next() .... 阅读全文
posted @ 2020-08-03 16:48 Action_swt 阅读(172) 评论(0) 推荐(0) 编辑
摘要:function getBase64 (file) { return new Promise(function (resolve, reject) { let reader = new FileReader() let imgResult = '' reader.readAsDataURL(file 阅读全文
posted @ 2020-07-27 11:55 Action_swt 阅读(1480) 评论(0) 推荐(0) 编辑
摘要:import Vue from 'vue' import axios from 'axios' Vue.prototype.$download = function download(url,param) { axios.get(url, { responseType: 'blob', params 阅读全文
posted @ 2020-07-27 11:37 Action_swt 阅读(687) 评论(0) 推荐(0) 编辑
摘要:var star='2019-2-26'//date1:小日期 对比时间日期 var end='2019-3-5'//date2:大日期 当前日期 function DateMinus(date1,date2){ var sdate = new Date(date1); var now = new 阅读全文
posted @ 2020-07-14 14:12 Action_swt 阅读(1374) 评论(0) 推荐(0) 编辑
摘要:<script type="text/javascript">function checknum(){ var obj = document.getElementById("num"); var reg = new RegExp("^[0-9]*$"); if(!reg.test(obj.value 阅读全文
posted @ 2020-06-24 15:21 Action_swt 阅读(828) 评论(0) 推荐(0) 编辑
摘要:function randomColor1(){ var r=Math.floor(Math.random()*256); var g=Math.floor(Math.random()*256); var b=Math.floor(Math.random()*256); //在控制器中显示出随机生成 阅读全文
posted @ 2020-06-11 14:14 Action_swt 阅读(154) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示