随笔分类 -  方法

摘要:前端技术中的常用通信方案原生js通信 1. Event: 在发送方注册事件,并在接收方监听该事件来进行通信。发送方在适当的时机触发事件,接收方收到事件后执行相应的处理 event-example <body> <div id="wrap"> <button id="message">发送消息</button> <div i 阅读全文
posted @ 2024-02-20 11:13 libenzheng 阅读(260) 评论(0) 推荐(0)
摘要:安装 npm install image-compressor.js // 压缩js importImageCompressorfrom'image-compressor.js' // 上传图片 asyncPostUpload (previewUrl, file, oss, index=-1) { 阅读全文
posted @ 2022-09-01 10:49 libenzheng 阅读(219) 评论(0) 推荐(0)
摘要:vuex 公共数据存储, 简单介绍一下怎么使用的(这是主要是配上一篇 Axios 请求配置统一封装(加入缓存机制)) 代码如下:import Vue from 'vue'; import Vuex from 'vuex'; Vue.use(Vuex); export default new Vuex 阅读全文
posted @ 2021-07-14 14:32 libenzheng 阅读(564) 评论(0) 推荐(0)
摘要:created () { window.addEventListener('scroll', this.onScroll) }, methods: { onScroll () { let innerHeight = document.querySelector('#app').clientHeigh 阅读全文
posted @ 2021-04-22 09:54 libenzheng 阅读(487) 评论(0) 推荐(0)
摘要:console.log(this.initTime('2020-06-27 15:30', '2020-10-27 15:30')) // start, end 开始结束时间 2020-06-27 15:30)" initTime (start, end) { const timeLength =  阅读全文
posted @ 2021-02-06 10:06 libenzheng 阅读(843) 评论(0) 推荐(0)
摘要:直接上代码: // 获取组件下gallery 文件夹下的 .vue 文件 const files = require.context('@/components/gallery/', true, /\.vue$/); // 空对象接收gallery const gallery = {}; files 阅读全文
posted @ 2021-02-01 15:50 libenzheng 阅读(522) 评论(0) 推荐(0)
摘要:数组处理方法:1. push() --追加数据 2. pop() --删除最后一个数据 3. shift() --删除第一个元素 4. unshift() --添加前面一个数据 5. splice(1,1)splice(1,0,data)splice(1,1,data) --从第几个删除、添加、替换 阅读全文
posted @ 2020-07-14 14:15 libenzheng 阅读(40) 评论(0) 推荐(0)
摘要:这是Prompt 组件是在离开当前页面是触发 import { Link, Prompt } from 'react-router-dom' // 在页面中添加标签 <Prompt when={isShelf} // 一个状态when= true 是才触发下面方法 message={this.unA 阅读全文
posted @ 2020-05-22 10:18 libenzheng 阅读(1688) 评论(0) 推荐(0)
摘要:react 的验证码倒计时 constructor(props) { super(props); this.state = { code: '', title: '注册/登录', count: 60, isCode: false, codeTitle: '获取验证码', }; } handlecha 阅读全文
posted @ 2020-05-22 10:17 libenzheng 阅读(213) 评论(0) 推荐(0)
摘要:1 .Cookie 优点: 可配置到期规则(可设置缓存时间) 不需要任何服务器资源 Cookie 存储在客户端并在发送后由服务器读取。 数据持久性 缺点: 大小受到限制 4kb 用户配置为禁用 有些用户禁用了浏览器或客户端设备接收 Cookie 的能力。 存放在前端的,不安全 要使用它前端必须要有服 阅读全文
posted @ 2020-03-16 10:30 libenzheng 阅读(41) 评论(0) 推荐(0)