随笔分类 -  js

摘要:什么是Fabric.js? Fabric.js 是一个强大的H5 canvas框架,在原生canvas之上提供了交互式对象模型,通过简洁的api就可以在画布上进行丰富的操作。 Fabric.js有什么功能? 使用Fabric.js,你可以在画布上创建和填充对象; 比如简单的几何形状 - 矩形,圆形, 阅读全文
posted @ 2020-11-12 16:57 rachelch 阅读(19675) 评论(8) 推荐(4)
摘要:// assets/js/mixin.js let mixin = { mounted() { var m = navigator.userAgent //解决iPhone6s plus 失去焦点以后,先隐藏软键盘,再弹出 (主要原因是setTimeout引起的,没有setTimeout就不会出现这 阅读全文
posted @ 2020-09-28 14:03 rachelch 阅读(381) 评论(0) 推荐(0)
摘要:// find() 返回符合条件的数组项,如果没有返回undefined Array.prototype.myFind = function(callback){ for(let i=0;i<this.length;i++){ if(callback(this[i], i)){ return thi 阅读全文
posted @ 2020-08-12 14:45 rachelch
摘要:一、async/await的优势在于处理 then 链 单一的 Promise 链并不能发现 async/await 的优势,但是,如果需要处理由多个 Promise 组成的 then 链的时候,优势就能体现出来了(很有意思, Promise 通过 then 链来解决多层回调的问题,现在又用 asy 阅读全文
posted @ 2020-08-10 13:51 rachelch
摘要://jQuery实现textarea高度根据内容自适应 $.fn.extend({ txtaAutoHeight: function () { return this.each(function () { var $this = $(this); if (!$this.attr('initAttrH 阅读全文
posted @ 2020-08-03 15:11 rachelch
摘要:// html <div class="preview" v-show="previewImg" @click="previewImg=''"><img :src="previewImg" alt="" /></div> <div class="uploadBox2"> <div class="up 阅读全文
posted @ 2020-07-28 15:04 rachelch
摘要:1、Vue父组件可以监听到子组件的生命周期吗?如果能请写出你的实现方法 1)实现方法一 比如有父组件 Parent 和子组件 Child ,如果父组件监听到子组件挂载 mounted 就做一些逻辑处理,可以通过以下写法实现: // Parent.vue <Child @mounted="doSome 阅读全文
posted @ 2020-07-03 17:52 rachelch 阅读(248) 评论(0) 推荐(0)
摘要:1.Promise的立即执行性 var p = new Promise(function(resolve, reject){ console.log("create a promise"); resolve("success"); }); console.log("after new Promise 阅读全文
posted @ 2020-07-01 16:55 rachelch
摘要:window.location.href(当前URL) 结果如下: http://www.link.com:8080/test?id=123&username=xxx window.location.protocol(协议) 结果如下: http: window.location.host(域名 + 阅读全文
posted @ 2020-07-01 10:01 rachelch
摘要:解决的核心思想就是:不允许用户访问到带 from 参数的地址,如果收到 from 参数,就去掉 from 重新拼接 url ,重定向到不带 from 的 url router.beforeEach((to, from, next) => { if (window.location.href.incl 阅读全文
posted @ 2020-07-01 09:53 rachelch
摘要:数组常用方法: 数组解构赋值应用 // 交换变量 [a, b] = [b, a] [o.a, o.b] = [o.b, o.a] // 生成剩余数组 const [a, ...rest] = [...'asdf'] // a:'a',rest: ["s", "d", "f"] 数组浅拷贝 const 阅读全文
posted @ 2020-06-24 17:12 rachelch
摘要:ios中,用 swiper 实现轮播图 swiper圆角,图片滑动的时候会先变成直角然后变成圆角(vant) 解决方法: 在swiper的父盒子上加overflow:hidden 和 transform: translateY(0); <div class="my-swipe-box"> <van- 阅读全文
posted @ 2020-06-15 13:36 rachelch
摘要:移动端页面中有一个search input想监听搜索键盘中的 “搜索按钮”,看了下keycode是13,但是每次按下回车,回报非法 return 的错误 报错: Uncaught SyntaxError: Illegal return statement 代码如下: <form action="ja 阅读全文
posted @ 2020-05-12 15:08 rachelch 阅读(1700) 评论(0) 推荐(0)
摘要:window.onresize事件来做突破点的,但是 ios 中软键盘的弹起收起并不触发 window.onresize 事件 总结:1、在 ios 中软键盘弹起时,仅会引起 $(‘body’).scrollTop 值改变,但是我们可以通过输入框的获取焦点情况来做判断,但也只能在 ios 中采用这个 阅读全文
posted @ 2020-05-09 17:21 rachelch
摘要:position: fixed; 在 iOS手机中会存在一个失效情况: 1、针对当前内容高度小于屏幕高度时: 上下滑动页面时候,发现之前 fixed 定位在顶部的元素会跟随页面滚动,变成了absolute定位的效果。 2、针对当前内容高度大于屏幕高度时: 之前 fixed 定位在顶部的 View 不 阅读全文
posted @ 2020-05-09 15:47 rachelch
摘要:转载: 这个教程,真的让我学会了正则表达式 阅读全文
posted @ 2020-05-08 15:50 rachelch
摘要:PS:本文说的,并非如何用js创建流、创建文件、实现下载功能。 而是说的:你已知一个下载文件的后端接口,前端如何请求该接口,实现点击按钮、下载文件到本地。(可以是zip啦、excel啦都是一样) 有两个方法:window.open()和通过form表单来提交。 方法一:window.open("下载 阅读全文
posted @ 2020-04-17 11:37 rachelch 阅读(5163) 评论(0) 推荐(0)
摘要:参考文章: IOS 配置 微信 JS SDK 报 invalid signature签名错误 阅读全文
posted @ 2020-04-08 17:14 rachelch 阅读(957) 评论(0) 推荐(0)
摘要:复制文字 <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <meta name='viewport' content='width=device-width, initial-scale=1.0, user-scalable=no'/> <m 阅读全文
posted @ 2020-03-24 16:59 rachelch
摘要:$("body").animate({"scrollTop": top})被Firefox支持问题的解决: 其实是因为使用了body的: $("body").animate({"scrollTop": top}); 只被chrome支持,而不被Firefox支持。 而使用html的: $("html 阅读全文
posted @ 2020-03-20 16:52 rachelch