一、判断空对象:
1.JSON.stringify(obj)=‘{}’//true;
2.返回对象中属性名组成的数组:let arr = Object.getOwnPropertyNames(obj);arr.length=0//true;
3.返回对象中属性名组成的数组:Object.keys(obj)
二、判断对象里有某个属性:
1.判断是否为对象自身的属性:obj.hasOwnProperty(‘a’);
2.可能来自原型:Reflect.has(obj,‘a’);
3.可能来自原型:‘a’ in obj
三、promise.all及其缺点
四、h5开发注意事项
1.样式适应
方案1:
<template>
<div id="app" style="transform-origin: 0 0;transform: scale(1,1);width: 2160px;height: 3840px">
<router-view />
</div>
</template>
<script>
export default {
name: 'App',
mounted() {
this.scale();
},
methods: {
scale() {
let node = document.getElementById('app');
let currentRatioX = document.documentElement.clientWidth / node.clientWidth;
let currentRatioY = document.documentElement.clientHeight / node.clientHeight;
let scaleValue = this.$route.query.scale;
if (scaleValue === '0') {
node.style.transform = `scale(${currentRatioX},${currentRatioY})`;
} else if (scaleValue === '1') {
node.style.transform = `scale(${currentRatioX},${currentRatioX})`;
} else if (scaleValue === '2') {
node.style.transform = `scale(${currentRatioY},${currentRatioY})`;
}
},
},
}
</script>
方案2: