随笔分类 - javascript
摘要:vue could not resolve解决方法 package.json package-lock.json改成正确的文件就好了 最好的方法就是重新新建项目 然后npm install安装 这样保证不会有版本的问题出现
阅读全文
摘要:javascript gsap 动画2种常用写法 import gsap from "gsap"; gsap.to(".ball", { keyframes: { "0%": { yPercent: 0, scaleX: 1, scaleY: 1 }, "7%": { yPercent: 5, sc
阅读全文
摘要:我只写vue3的改动 import { createApp } from 'vue' import App from './App.vue' import router from './router' console.log(router); const app = createApp(App) a
阅读全文
摘要:vue swiper 初始化巨坑解决方案 1延迟修改属性初始化方案 <swiper class="swiper" :options="swiperOptionTop" ref="swiper1"> <swiper-slide class="slide-1" v-for='item in imgLis
阅读全文
摘要:const CancelToken = axios.CancelToken; let cancel; // 这个模拟接口写个sleep2秒 可以看到效果 axios.get('/moban/aass', { cancelToken: new CancelToken(function executor
阅读全文
摘要:vue2异步更新原理 直接开个断点调试 不用去看他执行了哪些代码 看了也记不住 直接看他的具体架构就行 就是执行了什么大函数 1 先执行update方法 把walker加入队列 2 执行nexttick方法 flushSchedulerQueue是刷新walk队列的 3执行 timerfunc 异步
阅读全文
摘要:javascript 数组vuex 绑定方法 放弃state.isActive[slideIndex] = 1; 用 Vue.set(state.isActive,slideIndex,1) 切记 import Vue from 'vue' 一定要引用!!!!!!!!!!!!!!!!!!!!!!!!
阅读全文
摘要:var a=new Image(); //这个是原生的JS实例化 a.src='https://oss.knowway.cn/lanchengcocmanghe/images/1/p1_3.png'; a.onload=function(){ alert("完成加载"); } alert("0");
阅读全文
摘要:const element = document.getElementById('some-element-you-want-to-animate'); let start; function step(timestamp) { if (start undefined) start = timest
阅读全文
摘要:javascript防止xss攻击的方法 简单点 读取标签的时候 判断下 没转义的转义下
阅读全文
摘要:javascript 直角系坐标和屏幕坐标的关系 很多做过游戏开发的人 会遇到这个问题 他们2个关系就是Y轴要反一下(0,0 都是左上角) 所以计算的时候要先转换 Y 加个负数 再操作 操作完再转换回来 确实麻烦。。
阅读全文
摘要:javascript html2canvas手机端生成截图问题 html2canvas(document.querySelector("#capture"),{scale:3}).then(canvas => { $('#haibaopic').attr('src',canvas.toDataURL
阅读全文
摘要:javascript H5跳转小程序的方法 <script type="text/javascript" src="https://res.wx.qq.com/open/js/jweixin-1.6.0.js"></script> 引用的要1.6最新的哦 才支持 这个非常重要!!! <wx-open
阅读全文
摘要:javascript 生成blob url的方法 <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Blob Url</title> </head> <body> <video id="video" width
阅读全文
摘要:javascript tweenmax做倒计时的方法 <div class="p2_wrap1_wrap1"id="scoreDisplay">30.00</div> var demo = { score: 30 }, scoreDisplay = document.getElementById("
阅读全文
摘要:javascript原型链理解 function Fn() { this.n = 20 } Fn.prototype.say= function() { console.log(this.n) } var deb = new Fn() 不停的__proto__往下搜索有没有相应的方法和属性 prot
阅读全文
摘要:javascript检测内存泄漏的方法 这个线条是上升状态的 明显就是内存 内存满了 浏览器就是崩溃的时候 如果要知道哪个代码引擎的 只能用排除法
阅读全文
摘要:识别canvas和webgl的方法 var c=document.getElementById("myCanvas"); var ctx=c.getContext("2d"); console.log(ctx); 返回的是CanvasRenderingContext2D 这类 var c=docum
阅读全文
摘要:javascript 放大缩小精灵升级版 function xuanzhuanactnew(dianthat, dianjix, dianjiy, zhongxinx, zhongxiny){ var newangle = getjiaodu(dianjix, dianjiy, zhongxinx,
阅读全文
摘要:threejs 自适应需要注意的问题 renderer = new THREE.WebGLRenderer(); renderer.setSize(window.innerWidth, window.innerHeight,false); renderer = new THREE.WebGLRend
阅读全文