设置背景图
多出来的字设置为...
手机号正则
vue路由首位
vue图片上传
前端
vuestore持久化
后端
tsredux下载
vue 重定向 path redirect
react 重定向 to from
npm cache clean --force 清缓存
this.$router.push({
path:"/detail",
params:{
name:'nameValue',
code:10011
}
});
vue 路由传参
/ this.props.history.push({
// pathname:"/detail",
// state:{
// id
// }
// })
react 路由传参
转大写
tofixed 加小数点
process是node的内置全局进程对象
设置淘宝镜像:npm config set registryhttps://registry.npm.taobao.org
查看当前资源:npm config get registry还原到npm仓库:npm config set registryhttps://registry.npmjs.org
git clone +远程仓库地址
git status 查看仓库状态
git add . 存储到暂存区
git commit -m "1"
git push 想远程仓库推送代码
get后面跟着传参 是query获取
get路径后面拼接 是params接受
post 获取是body
gitlab 密钥
查看本地分支
git branch
查看远程分支 git branch -r
查看所有分支 git branch -a
切换分支 git checkout ""
切换并新建分支 git checkout -b ""
合并分支 git merge ""
拉去主分支代码 git pull origin ""
删除远程分支 git push origin :""
释放eject
先退出你这个下载的项目 先git add . git commit -M "" 保存提交一下 在进入项目 释放eject
配@符号
"@": paths.appSrc,
转换时间
import moment from "moment";
moment.updateLocale("en", {
relativeTime: {
future: " %s",
past: "%s ago",
s: "秒",
ss: "%d 秒前",
m: "分前",
mm: "%d 分前",
h: "小时",
hh: "%d 小时前",
d: "天",
dd: "%d 天前",
M: "月",
MM: "%d 月前",
y: "年",
yy: "%d 年前",
},
});
媒体查询 @media(){
}
Mobx
目录
index.js里面
目录里面 class
用的话 引入
用数据
人口文件
滚动条样式
::-webkit-scrollbar-track-piece { //滚动条凹槽的颜色,还可以设置边框属性
background-color:#f8f8f8;
}
::-webkit-scrollbar {//滚动条的宽度
width:3px;
height:9px;
}
::-webkit-scrollbar-thumb {//滚动条的设置
background-color:#dddddd;
background-clip:padding-box;
min-height:28px;
}
::-webkit-scrollbar-thumb:hover {
background-color:#bbb;
}
uim layout组件面包屑
操作dom
vue3路由
修改vant自带样式 加 /deep/
数组去重 new Set
const arr=[1,2,3,5,5,5,7,9,55,]
console.log(Array.from(new Set(arr)) );
...[new Set(arr)]
去重
const arr=[1,2,3,5,5,5,7,9,55,]
console.log(Array.from(new Set(arr)) );
合并
var a=new Set([1,2,3])
var b=new Set([2,3,4])
console.log(Array.from(new Set([...a,...b])) );
并集
var a=new Set([1,2,3])
var b=new Set([2,3,4])
var c=new Set([...a].filter(x=>b.has(x)))
console.log(c);
差集
var a=new Set([1,2,3])
var b=new Set([2,3,4])
var c=new Set([...a].filter(x=>!b.has(x)))
console.log(c);
//sort排序
var a=[4,5,6,5,1,3,56,8,1,3,8]
console.log(a.sort((a,b)=>b-a));
//sort排序
// var a=[4,5,6,5,1,3,56,8,1,3,8]
var a = [
{
num: 1,
name: "yz",
},
{
num: 2,
name: "hh",
},
];
console.log(a.sort((a, b) => a.num - b.num));
axios二次封装
import axios from "axios";
var instance = axios.create();
instance.defaults.timeout = 2500;
instance.interceptors.request.use(
function (config) {
// 在发送请求之前做些什么
return {
...config,
headers: {
...config.headers,
token: localStorage.getItem("token")
? localStorage.getItem("token")
: null,
"api-request": "yes",
},
};
},
function (error) {
// 对请求错误做些什么
return Promise.reject(error);
}
);
// 添加响应拦截器
instance.interceptors.response.use(
function (response) {
// switch (response.status) {
// case 404:
// alert("找不到页面");
// break;
// case 400:
// alert("没有该用户");
// break;
// default:
// break;
// }
// 对响应数据做点什么
return response;
},
function (error) {
// 对响应错误做点什么
if (error && error.response) return Promise.reject(error.response.data);
return Promise.reject(error);
}
);
export default instance;
vue国际化
main.js
eslint
module.exports = {
root: true,
env: {
node: true
},
extends: ["plugin:vue/essential", "eslint:recommended", "@vue/prettier"],
parserOptions: {
parser: "babel-eslint"
},
plugins: ['vue'],
rules: {
"no-console": process.env.NODE_ENV === "production" ? "warn" : "off",
"no-debugger": process.env.NODE_ENV === "production" ? "warn" : "off",
// 添加⾃定义规则
'prettier/prettier': [
// eslint校验不成功后,error或2则报错,warn或1则警告,off或0则⽆提示
'error',
{
// 是否使用单引号
'singleQuote': true,
// 结束是否加分号
'semi': false,
'printWidth': 120,
}
]
}
};
import axios from 'axios'
import router from 'router'
import { VueAxios } from './axios'
import store from '@/store'
import gomeUI from 'gome-ui'
const notification = gomeUI.GNotification
// 创建 axios 实例
const request = axios.create({
// API 请求的默认前缀
baseURL: process.env.VUE_APP_API_BASE_URL,
timeout: 6000 // 请求超时时间
})
const requestLayer = store.getters.requestLayer
const defaultInterceptorRequest = {
ok(config) {
config.headers['Accept'] = 'application/json, */*'
const token = store.state.user.token
if (token) {
config.headers['token'] = token
}
return config
},
err(error) {
return Promise.error(error)
}
}
request.interceptors.request.use(defaultInterceptorRequest.ok, defaultInterceptorRequest.err)
// 响应拦截器
request.interceptors.response.use(
res => {
const data = res.data
const code = data.code
if (code === 401) {
if (!requestLayer) {
store.commit('userUpdate', { name: 'layer', value: true })
// 没有登录
notification.error({
message: data.message
})
store.dispatch('loginOut')
router.push('/login')
return Promise.reject(data.message)
} else {
return Promise.reject('登录失效了')
}
} else if (code === 403) {
// 没有权限
notification.error({
message: data.message
})
return Promise.reject(data.message)
}
return data
},
error => {
const response = error.response
const message = (response && response.message) || '网络错误'
notification.error({
message: message
})
return Promise.reject(error)
}
)
const installer = {
vm: {},
install(Vue) {
Vue.use(VueAxios, request)
}
}
export default request
export { installer as VueAxios, request as axios }