
js
小m的雨季
这个作者很懒,什么都没留下…
展开
-
vue $on 重复触发 解决方案
原理:绑定前先解绑以前的绑定//main.js中添加$bus,使用 this.$bus.$on , this.$bus.$emitVue.prototype.$bus = new Vue()Vue.prototype.addEvent = function (key, fallback) { this.$bus.$off(key); this.$bus.$on(key, fallback);};原创 2021-04-07 08:27:28 · 485 阅读 · 0 评论 -
web新开页面js(第三方登录重定向)
代码来源https://github.com/PanJiaChen/vue-element-admin向大佬致敬//新开页面jsexport default function openWindow(url, title, w, h) { // Fixes dual-screen position Most browsers Firefox const dualScreenLeft = window.screenLeft..原创 2020-07-24 11:05:28 · 442 阅读 · 0 评论 -
Vue 骚技巧,策略模式实现动态表单验证
策略模式(Strategy Pattern)又称政策模式,其定义一系列的算法,把它们一个个封装起来,并且使它们可以互相替换。封装的策略算法一般是独立的,策略模式根据输入来调整采用哪个算法。关键是策略的实现和使用分离。注意:本文可能用到一些编码技巧比如 IIFE(Immediately Invoked Function Expression, 立即调用函数表达式),ES6 的语法 let/const、箭头函数、rest 参数,短路运算符 等,如果还没接触过可以点击链接稍加学习 ~1. 你曾...转载 2020-07-22 11:20:12 · 279 阅读 · 0 评论 -
数组数据 转化为 树状结构数据
codepen地址:codepen地址var aTree = [ {"id": "1", "name": "动物", "pid": "0"}, {"id": "2", "name": "鸟类", "pid": "5"}, {"id": "3", "name": "无脊椎动物", "pid": "1"}, {"id": "4", "name": "哺乳动物", "pid": "5"}, {"id": "5", "name": "脊椎动物", "pid": "1原创 2020-07-16 15:32:50 · 1542 阅读 · 0 评论 -
金额格式化 处理 (每三位逗号分隔)
/* * formatMoney(s,type) 只针对元 * 功能:金额按千位逗号分隔,负号用- * 参数:s,需要格式化的金额数值. * 参数:type,判断格式化后的金额是否需要小数位. * 返回:返回格式化后的数值字符串. */const formatMoney = (s, type) => { var result = s; if (s < 0) { s = 0 - s; } if (/[^0-9\.]/.test(s)) { retu..原创 2020-07-16 09:55:18 · 1574 阅读 · 0 评论 -
ReactNative: Android与iOS平台兼容处理
方法一:创建不同的文件扩展名:*.android.js*.io.js方法二:import { Platform } from 'react-native';if (Platform.OS === 'android') { // Do something specific for Android } else if (Platform.OS === 'ios') { // Handle iOS} marginTop: Platform.OS === 'i原创 2020-07-13 14:06:57 · 441 阅读 · 0 评论 -
js 常用方法 arr data math string 常用方法
Array:slice(start,end) 从索引为start的开始取,取到索引为end的为止,end的取不到, 如果end为负数,表示索引为数组的长度+负数.toString() 把数组转换成字符串,每一项用,分割valueOf() 返回数组对象本身indexOf()从数组开头开始获取lastIndexof()从数组末尾开始获取获取数组中某元素的索引(位置) 如果要检索的数组值没有出现,则该方法返回 -1。push() 添加到数组的最后...原创 2020-07-09 16:09:26 · 285 阅读 · 0 评论 -
localStorage h5缓存代码
JSON.parse()转换为jsonJSON.stringify()转化为字符串// store.js h5使用缓存代码 export default{ fetch(STORAGE_KEY){ return JSON.parse(window.localStorage.getItem(STORAGE_KEY)||'[]') }, save(STORAGE_KEY,items){ window.localStorage.setItem(ST原创 2020-07-03 16:58:54 · 222 阅读 · 0 评论 -
react-native-swiper 内容循环的时候 pagenation 不变化
三元运算 :先判断要循环的数组长度,没有不显示 {arrayImg.length != 0 ? (<Swiper> </Swiper> ):(<View></View>)}原创 2020-06-30 17:31:12 · 418 阅读 · 0 评论 -
react-native 安卓下 webView自动播放
https://github.com/react-native-community/react-native-webview/issues/859<WebViewstyle={{ flex: 1 }}source={{ html }}mediaPlaybackRequiresUserAction={((Platform.OS !== 'android') || (Platform.Version >= 17)) ? false : undefined}userAgent="Mozill原创 2020-06-28 17:46:51 · 529 阅读 · 0 评论 -
react setState直接赋值对象
写法:可以自动解构对象到state中let a={bb:1} this.setState(a);使用{this.state.bb}就直接获取值原创 2020-06-17 16:32:37 · 2885 阅读 · 0 评论 -
webpack4 配置文件
根据webpack4做了基本配置文件https://github.com/minzhenyu/webpack4原创 2019-11-22 17:23:15 · 203 阅读 · 0 评论 -
vue demo整理
Vue-cnodejs - 基于vue重写Cnodejs.org的webappNeteaseCloudWebA...原创 2019-10-23 15:04:14 · 171 阅读 · 0 评论 -
checkbox全选反选事件不打勾解决方案
全选反选原创 2015-10-19 11:48:13 · 312 阅读 · 0 评论 -
ajax格式
ajax格式原创 2015-10-20 10:35:56 · 189 阅读 · 0 评论 -
ajax的异步刷新事件绑定问题
ajax的异步刷新事件绑定问题原创 2015-10-20 10:50:44 · 238 阅读 · 0 评论 -
json jquery 解析
json jquery 解析转载 2015-10-20 15:09:22 · 197 阅读 · 0 评论 -
jquery 停止动画 stop的几种用法
jquery 停止动画 stop的几种用法转载 2015-11-10 14:35:26 · 327 阅读 · 0 评论