1、滚动到页面的底部
scrollTopBottom = (vm) => {
let scrollHeight = Number(document.documentElement.scrollHeight || document.body.scrollHeight);
vm.$nextTick(()=>{
window.scrollTo(0, scrollHeight)
})
};
2、对数组根据其子元素的某个属性做分类(该属性有相同的值),并重新归纳到各自数组中
如对ip_location相同的值的对象数据做归纳,最后是新加坡的一个数组,上海的一个数组
代码比较简单,只有几行
// 对相同的ip_location做集合、分类 lists是原始数据
let Obj = {};
lists.forEach(item=>{
if(typeof Obj[item.ip_location] === 'undefined'){
Obj[item.ip_location] = [item]
}else{
Obj[item.ip_location].push(item)
}
})
for(let key in Obj){
this.results.push(Obj[key])
}