Vuex手册
Vuex使用手册安装npm install vuex@next --save
开始123456789101112131415161718192021import { createApp } from 'vue'import { createStore } from 'vuex'// 创建一个新的 store 实例const store = createStore({ state () { return { count: 0 } }, mutations: { increment (state) { state.count++ } }})const app = createApp({ /* 根组件 */ })// 将 store 实例作为插件安装app.use(store)
Apistatevue 组件使用state
12345comput ...
JS find,findIndex,filer,forEach,some,every,map,reduce 方法
Functionfind()返回第一个符合条件的项 不存在则返回undefined123let source = [1, 2, 3, 4, 5];const res = source.find(n => n === 8);console.log(res); //1
findIndex()返回第一个符合条件项的index 不存在则返回-1123let source = [1, 2, 3, 4, 5];const i = source.findIndex(n => n === 1);console.log(i); //0
filter()返回包含所有符合条件项的数组123let source = [1, 2, 3, 4, 5];const res = source.filter(n => n>3);console.log(res); //[4,5]
forEach()遍历数组 无返回值 可传参数 item,index,arr(数据源)123let source = [1, 2, 3, 4, 5];source.forEach((n,i,arr) => c ...
SVG 实现环形进度条
SVG 实现环形进度条效果
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657<div class="progress"> <svg width="200" height="200" viewBox="0 0 230 230" transform="rotate(270)" > <defs> <linearGradient id="orange" x1="0%" y1="0%" x2="100%" y2="0%"> <stop offset="0%" stop-color=" ...
whistle 抓包工具
关于whistlewhistle(读音[ˈwɪsəl],拼音[wēisǒu])基于Node实现的跨平台web调试代理工具,类似的工具有Windows平台上的Fiddler,主要用于查看、修改HTTP、HTTPS、Websocket的请求、响应,也可以作为HTTP代理服务器使用,不同于Fiddler通过断点修改请求响应的方式,whistle采用的是类似配置系统hosts的方式,一切操作都可以通过配置实现,支持域名、路径、正则表达式、通配符、通配路径等多种匹配方式,且可以通过Node模块扩展功能:
安装启动1 安装whistle$ npm install -g whistle
2 启动whistle$ w2 start
3 停止whistle$ w2 stop
4 配置代理1:代理服务器:127.0.0.1
2:默认端口:8899
5 代理配置方式1:Mac: System Preferences > Network > Advanced > Proxies > HTTP or HTTPS
2:Linux: Settings > Network > VP ...
IntersectionObserver
概述IntersectionObserver接口 提供了一种异步观察目标元素与其祖先元素或顶级文档视窗(viewport)交叉 状态的方法。祖先元素与视窗(viewport)被称为根(root)。
当一个IntersectionObserver对象被创建时,其被配置为监听根中一段给定比例的可见区域。 一旦IntersectionObserver被创建,则无法更改其配置,所以一个给定的观察者对象只能 用来监听可见区域的特定变化值;然而,你可以在同一个观察者对象中配置监听多个目标元素。
用法12345678910111213141516const option = { threshold: [0, 0.5, 1], root: document.querySelector('body'), rootMargin: "500px 0px"};const io = new IntersectionObserver(entries => { console.log(entries);}, option)// 开 ...
ES6 新增常用扩展
概述全称 ECMAScript 6.0 2015.06 发版;国际化组织ECMA 制定了浏览器脚本语言的标准,即ECMAScript;
以下只整理部分ES6扩展;
函数的扩展
参数默认值
1function fn(x = 1, y = 2, z) {};
箭头函数
1const fn = (a) => a;
catch 参数省略
12345try {} catch { // catch(err){}}
参数的尾逗号
1function fn(a, b,) {} //es2017之前报错
数组的扩展
扩展运算符
12345console.log(...[1, 2, 3]);// 1 2 3 [...'script']// ['s','c','r','i','p','t']
Array.from()
将类数组和部 ...
MySQL基础命令
Mysql常用命令
mysql -u root -p; 登录mysql;
select user,host from mysql.user; 查看所有用户
ALTER USER ‘root’@’localhost’ IDENTIFIED BY ‘password’ PASSWORD EXPIRE NEVER; #修改加密规则
ALTER USER ‘root’@’localhost’ IDENTIFIED WITH mysql_native_password BY ‘password’;更新密码
use mysql;
select user.plugin from user where user=’root’; 查看当前密码加密方式;
show databases; 查看所有数据库
show tables; 查看当前数据库下的数据表;
create database ; 创建数据库
drop database ; 删除数据库
select * from ; 从table表中查询所有列数据
select * from where i ...
module.exports, exports , export ,export default 的区别
module.exports 和 exports1 . Node 应用由模块组成,采用CommonJS 模块规范;
每个文件就是一个模块,有自己的作用域,在一个文件内定义的变量,函数,类都是私有的;
CommonJS规范规定,每个模块内部,module代表当前模块,module是一个对象,它的exports属性(即module.exports)是对外的接口。
1234var x=5;module.exports.x=x;//或者module.exports={x}
上面代码通过module.exports 输出变量x;
require 方法用于加载模块
12var x =require('./x.js');log(x);
2 . exports变量为了方便,Node为每个模块提供一个exports变量,指向module.exports,等同在每个模块头部,有一行这样的命令
12345var exports = module.exports;//使用 必须要导出一个具体的属性名exports.utils=()=>{};// ...
【TS】【05】TypeScript函数的类型
函数声明
定义函数的方式
函数声明123function utils (a){ return a ;}
函数表达式123let common =(a)=>{ return a ;}
TypeScript使用函数的类型 定义函数的输入与输出123function total (o:number,p:number):number{ return o+p;}
函数表达式123let total:(o:number,p:number) => number=(o:number,p:number):number=>{ return o + p ;}
接口定义123456interface TotalType { (o:number,p:number):number;}let total:TotalType=(o:number,p:number):number=>{ return o + p ;}
可选参数和参数默认值 ...
【TS】【04】TypeScript数组的类型
[类型+方括号]表示法1let list:number[]=[1,2,3,4,5];
数组泛型1let list:Array<number>=[122,33,55,18];
用接口表示数组1234interface NumberArray { [index: number]: number;}let fibonacci: NumberArray = [1, 1, 2, 3, 5];
类数组12345678interface IArguments { [index: number]: any; length: number; callee: Function;}function sum() { let args: IArguments = arguments;}
any 在数组中的应用 1let list:any[]=['tom',18,false];