1.一维数组变为二维数组方法
arraryTrans(num,arr){
const newArr = [];
while(arr.length > 0) {
newArr.push(arr.splice(0, num));
}
return newArr;
}
2.获取元素距离视口的位置
dom.getBoundingClientRect(). top/right/bottom/left
3.echarts 标线
option = {
tooltip: {
trigger: 'axis'
},
xAxis: {
type: 'category',
boundaryGap: false,
data: ['周一', '周二', '周三', '周四', '周五', '周六', '周日']
},
yAxis: {
type: 'value',
axisLabel: {
formatter: '{value} °C'
},
max: 15
},
series:{
data:[2,8,11,13,6,5,10],
type: 'line',
markLine:{
name: 'aa',
label:{
show:true,
position:'middle',
formatter:'wwwwww'
},
data:[
[{
coord: ['周四', 13],
},
{
coord: ['周五', 13]
}],
[{
coord: ['周五', 13],
},
{
coord: ['周五', 6],
value:10,
itemStyle:{
normal:{
label:{
show:true,
position:'middle',
formatter:'差值',
color:'blue',
fontSize:16
}
}
},
}]
]
}
}
};
4.echarts formatter
// formatter: function (data) {
// if (data.name == "最大值") {
// let maxText = [
// '{a|' +data.name + '}',
// '{b|' +data.value + 'MW}',
// ]
// return maxText.join(' ')
// } else {
// let minText = [
// '{a|' +data.name + '}',
// '{c|' +data.value + '}',
// ]
// return minText.join('\n')
// }
// },
// position: [10, 5],
// align :"left",
// rich: {
// a: {
// fontSize: '14',
// color: '#00FF00',
// },
// b: {
// color: 'white',
// fontSize: '14',
// fontWeight: '100',
// },
// c: {
// color: 'red',
// fontSize: '14',
// fontWeight: '400',
// }
// },
5.页面加空格码
空格 \xa0
6.滚动条样式
/*定义滚动条高宽及背景 高宽分别对应横竖滚动条的尺寸*/
::-webkit-scrollbar{
width: 10px; /*滚动条宽度*/
height: 10px /*滚动条高度*/
}
/*定义滚动条轨道 内阴影+圆角*/
::-webkit-scrollbar-track{
/*滚动条的背景区域的内阴影*/
box-shadow:0px 1px 3px rgba(0,0,0,0.3) inset;
/*滚动条的背景区域的圆角*/
border-radius: 10px;
/*滚动条的背景颜色*/
background-color: #ddd;
}
/*定义滑块 内阴影+圆角*/
::-webkit-scrollbar-thumb{
/*滚动条的内阴影*/
box-shadow:0px 1px 3px rgba(0,0,0,0.3) inset;
/*滚动条的圆角*/
border-radius: 10px;
/*滚动条的背景颜色*/
background-color: #aaa;
}
上传文件
export function headerPost(url, data) {
return axios({
url: url,
method: 'post',
headers: { "Content-Type": "multipart/form-data" },
data: data
})
}
export const fileManageUploadApi = (params, data) => headerPost(`/xxx/xxx/xxxx?${params}`, data);
uploadFiles(params){
let fd = new FormData();
fd.append("file", params.file);
let infos= {}
let data = fd
fileManageUploadApi(qs.stringify(infos), data).then( res=> {
if(res.data) {
messages("success", "上传成功");
}else if(res.data == false && res.message != '') {
messages("error", res.message);
}else {
messages("error", "上传失败");
}
})
}
webpack配置 提示
// ./webpack.config.js
// 一定记得运行 Webpack 前先注释掉这里。
// import { Configuration } from 'webpack'
/**
* @type {Configuration}
*/
const config = {
entry: './src/index.js',
output: {
filename: 'bundle.js'
}
}
通常,当我们克隆一个对象时,我们使用赋值的方式来复制属性,像这样:
for (let key in user) {
clone[key] = user[key]
}
……但是,这并不能复制标志。所以如果我们想要一个“更好”的克隆,那么 Object.defineProperties 是首选。
另一个区别是 for..in 会忽略 symbol 类型的属性,但是 Object.getOwnPropertyDescriptors 返回包含 symbol 类型的属性在内的 所有 属性描述符。
let clone = Object.defineProperties({}, Object.getOwnPropertyDescriptors(obj))
//我们可以使用 Object.create 来实现比复制 for..in 循环中的属性更强大的对象克隆方式:
let clone = Object.create(Object.getPrototypeOf(obj), Object.getOwnPropertyDescriptors(obj));
禁用eslint lintOnSave: false,
creatInterval(msg) {
let timer = setInterval(() => {
console.log(msg)
}, 1000)
this.$once('hook:beforeDestroy', function() {
clearInterval(timer)
})
}
npm 安装一些依赖报错 配置npm
sharp_binary_host = https://npm.taobao.org/mirrors/sharp
sharp_libvips_binary_host = https://npm.taobao.org/mirrors/sharp-libvips
profiler_binary_host_mirror = https://npm.taobao.org/mirrors/node-inspector/
fse_binary_host_mirror = https://npm.taobao.org/mirrors/fsevents
node_sqlite3_binary_host_mirror = https://npm.taobao.org/mirrors
sqlite3_binary_host_mirror = https://npm.taobao.org/mirrors
sqlite3_binary_site = https://npm.taobao.org/mirrors/sqlite3
sass_binary_site = https://npm.taobao.org/mirrors/node-sass
electron_mirror = https://npm.taobao.org/mirrors/electron/
puppeteer_download_host = https://npm.taobao.org/mirrors
chromedriver_cdnurl = https://npm.taobao.org/mirrors/chromedriver
operadriver_cdnurl = https://npm.taobao.org/mirrors/operadriver
phantomjs_cdnurl = https://npm.taobao.org/mirrors/phantomjs
python_mirror = https://npm.taobao.org/mirrors/python
registry = https://registry.npm.taobao.org/
disturl = https://npm.taobao.org/dist
//registry.npmjs.org/:_authToken=43331cb5-0c98-4e1c-8585-a2f8eb9db797