1.一維數(shù)組變?yōu)槎S數(shù)組方法
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 標(biāo)線
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.頁(yè)面加空格碼
空格 \xa0
6.滾動(dòng)條樣式
/*定義滾動(dòng)條高寬及背景 高寬分別對(duì)應(yīng)橫豎滾動(dòng)條的尺寸*/
::-webkit-scrollbar{
width: 10px; /*滾動(dòng)條寬度*/
height: 10px /*滾動(dòng)條高度*/
}
/*定義滾動(dòng)條軌道 內(nèi)陰影+圓角*/
::-webkit-scrollbar-track{
/*滾動(dòng)條的背景區(qū)域的內(nèi)陰影*/
box-shadow:0px 1px 3px rgba(0,0,0,0.3) inset;
/*滾動(dòng)條的背景區(qū)域的圓角*/
border-radius: 10px;
/*滾動(dòng)條的背景顏色*/
background-color: #ddd;
}
/*定義滑塊 內(nèi)陰影+圓角*/
::-webkit-scrollbar-thumb{
/*滾動(dòng)條的內(nèi)陰影*/
box-shadow:0px 1px 3px rgba(0,0,0,0.3) inset;
/*滾動(dòng)條的圓角*/
border-radius: 10px;
/*滾動(dòng)條的背景顏色*/
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
// 一定記得運(yùn)行 Webpack 前先注釋掉這里涣易。
// import { Configuration } from 'webpack'
/**
* @type {Configuration}
*/
const config = {
entry: './src/index.js',
output: {
filename: 'bundle.js'
}
}
通常晨炕,當(dāng)我們克隆一個(gè)對(duì)象時(shí)歇万,我們使用賦值的方式來(lái)復(fù)制屬性,像這樣:
for (let key in user) {
clone[key] = user[key]
}
……但是踱侣,這并不能復(fù)制標(biāo)志昆码。所以如果我們想要一個(gè)“更好”的克隆,那么 Object.defineProperties 是首選炕吸。
另一個(gè)區(qū)別是 for..in 會(huì)忽略 symbol 類型的屬性姿染,但是 Object.getOwnPropertyDescriptors 返回包含 symbol 類型的屬性在內(nèi)的 所有 屬性描述符背亥。
let clone = Object.defineProperties({}, Object.getOwnPropertyDescriptors(obj))
//我們可以使用 Object.create 來(lái)實(shí)現(xiàn)比復(fù)制 for..in 循環(huán)中的屬性更強(qiáng)大的對(duì)象克隆方式:
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 安裝一些依賴報(bào)錯(cuò) 配置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