Skip to content

Commit

Permalink
wip: 获取dpr
Browse files Browse the repository at this point in the history
  • Loading branch information
GauharChan committed Jan 11, 2024
1 parent 3f5a9e9 commit ed5360e
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions docs/工作常用代码.md
Original file line number Diff line number Diff line change
Expand Up @@ -965,3 +965,39 @@ export function downLoadByBlob(res) {
window.URL.revokeObjectURL(href); // 释放掉blob对象
}
```

### 微信H5打开小程序

https://developers.weixin.qq.com/doc/offiaccount/OA_Web_Apps/Wechat_Open_Tag.html#21

### web获取dpr

传递`canvas``context`

```ts
function getRatio (context: any): number {
if (!context) {
return 1
}
const backingStore =
context.backingStorePixelRatio ||
context.webkitBackingStorePixelRatio ||
context.mozBackingStorePixelRatio ||
context.msBackingStorePixelRatio ||
context.oBackingStorePixelRatio ||
context.backingStorePixelRatio ||
1
return (window.devicePixelRatio || 1) / backingStore
}
```











0 comments on commit ed5360e

Please sign in to comment.