1.实现创造a标签完成点击下载功能。
const elink = document.createElement('a');
// name为后台返给前端的文件名,后缀名必须加,后台有返回后缀就不用管,不然下载在本地不好打开。
elink.download = '表格数据' + '.json';
elink.style.display = 'none';
const blob = new Blob([JSON.stringify(this.storageJSON)]);
elink.href = URL.createObjectURL(blob);
document.body.appendChild(elink);
elink.click();
document.body.removeChild(elink);
2.prototype.hasOwnProperty.call
Object.prototype.hasOwnProperty.call(target, privatePropName)
主要是为了避免object上没有property.call的属性
使用call的原因
If obj inherits from null not Object.prototype
If hasOwnProperty has been redeclared on obj
If hasOwnProperty has been redeclared in obj's prototype chain
3. 宽高表示
offsetWidth = 对象本身的宽度(width+padding+borber包括滚动条)
clientWidth = 对象可视宽度(width+padding)
scrollWidth = 实际内容的宽度
offsetLeft = 相对于父级定位元素,在X方向的偏移量(如果本身没设置margin,则与style.left相同)
innerWidth 浏览器窗口可视区宽度(不包括浏览器控制台、菜单栏、工具栏,滚动条)
innerHeight 浏览器窗口可视区高度(不包括浏览器控制台、菜单栏、工具栏,滚动条)
pageXOffset 和 pageYOffset 属性返回文档在窗口左上角水平和垂直方向滚动的像素
4.resize
浏览器调整窗体大小事件
5.svg在angular里的变量引用
<svg height="100" width="100">
<circle fill="white"
[attr.cx]="parsedSize/2"
[attr.cy]="parsedSize/2"
[attr.r]="radius"
[attr.stroke]="stroke"
[attr.stroke-width]="strokeWidthCapped"
[attr.stroke-dasharray]="circumference"
[attr.stroke-dashoffset]="(1 - parsedComplete) * circumference"/>
</svg>