js基本实现功能统计,方便以后直接拿来ctrl+c,ctrlv

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>

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值