随笔分类 - javascript
摘要:1. hasOwn 是否是对象本身拥有的属性 var hasOwnProperty = Object.prototype.hasOwnProperty; function hasOwn (obj, key) { return hasOwnProperty.call(obj, key) } hasOw
阅读全文
摘要:/*判断一个元素是否在数组中*/ contains (arr, val) { return arr.indexOf(val) != -1 ? true : false; } /** * @param {arr} 数组 * @param {fn} 回调函数 * @return {undefined}
阅读全文
摘要:/** * 去除空格 * @param {str} * @param {type} * type: 1-所有空格 2-前后空格 3-前空格 4-后空格 * @return {String} */ trim (str, type) { type = type || 1 switch (type) {
阅读全文
摘要:/** * 格式化时间 * * @param {time} 时间 * @param {cFormat} 格式 * @return {String} 字符串 * * @example formatTime('2018-1-29', '{y}/{m}/{d} {h}:{i}:{s}') // -> 20
阅读全文
摘要:1.type 类型判断 isString (o) { //是否字符串 return Object.prototype.toString.call(o).slice(8, -1) 'String' } isNumber (o) { //是否数字 return Object.prototype.toSt
阅读全文
摘要:/* 全选/全不选 */ function selectAll(objSelect) { if (objSelect.checked == true) { $("input[name='chkId']").attr("checked", true); $("input[name='chkAll']"
阅读全文
摘要:class StorageFn { constructor () { this.ls = window.localStorage; this.ss = window.sessionStorage; } /* cookie */ /*设置cookie*/ setCookie (name, value, day) { var setting = arguments[0]; if (Object.pro
阅读全文
摘要:防抖:当持续触发事件时,一定时间段内没有再触发事件,事件处理函数才会执行一次。如果设定的时间到来之前,又一次触发了事件,就重新开始延迟 节流:当持续触发事件时,保证一定时间段内只调用一次事件处理函数(例如:尿不尽)
阅读全文
摘要:因为vue主要是通过数据劫持来实现的,通过get、set来完成数据的读取和更新 这里简单实现data,v-model,computed 1模版 js
阅读全文
摘要:页面结构 html <!DOCTYPE html><html><head> <title></title></head><body><header> @@@include('./dd/header.html')</header></body></html>
阅读全文
摘要:import axios from 'axios' import qs from 'qs' const baseURL = "http://10.4.108.117:8081/" exports.install = function (Vue, options) { Vue.prototype.get = function (url, data, success) { axios...
阅读全文
摘要:创建时间: - 查询 重置 startTimeOptions: { disabledDate(date) { if (date) { return (da...
阅读全文
摘要://mock/index.js import Mock from 'mockjs' //引入mockjs,npm已安装 import { Random,toJSONSchema } from 'mockjs' // 引入random对象,随机生成数据的对象,(与占位符@一样) Mock.setup({ timeout:1000 //设置请求延时时间 }) const getdata = ...
阅读全文
摘要:browser: { chrome: /chrome\/(\d+\.\d+)/i.test(navigator.userAgent) ? +RegExp["\x241"] : undefined, firefox: /firefox\/(\d+\.\d+)/i.test(navigator.userAgent) ? +RegExp["\x241"] : undef...
阅读全文
摘要:数据交互: 1.http协议 2.form 3.ajax--不能跨域,官方 单向 4.jsonp--跨域 不推荐(不支持post) 5.websocket--双向 http协议 协议 1.无状态 客户端访问服务器之后,服务器不能记住客户端 2.连接过程 客户端发送请求到服务器,服务器返回数据 3.x
阅读全文
摘要:echarts 折线图的鼠标移动上去小点显示样式修改 tooltip:{ trigger:'axis', formatter:function(a){ var res = ''; var nameList = a; for(var i=0; i<a.length; i++){ if(nameList
阅读全文
摘要:在 webpack.dev.conf.js文件中 /* jsonServer */ /*引入json-server*/ const jsonServer = require('json-server') /*搭建一个server*/ const apiServer = jsonServer.crea
阅读全文
摘要:后台传给我数字 例如 :10000000 前端需要转化为财务所用的格式 1,000,000.00
阅读全文
摘要:// 有三种方式获取,三种方式的区别 //time1 = date.getTime(); //time2 = date.valueOf(); //time3 = Date.parse(date); //第一、第二种:会精确到毫秒 //第三种:只能精确到秒,毫秒将用0来代替 var a=time1-N
阅读全文

浙公网安备 33010602011771号