Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

小程序跟H5环境下,怎么让canvas根据不同机型宽高尺寸自适应? #179

Closed
My-Gao opened this issue Dec 7, 2021 · 13 comments

Comments

@My-Gao
Copy link

My-Gao commented Dec 7, 2021

因为单位都是px的,怎么修改成rpx呢?求大佬解答下

@buuing
Copy link
Owner

buuing commented Dec 7, 2021

提问前必看!

@My-Gao
Copy link
Author

My-Gao commented Dec 7, 2021

我用的是uniapp,hb插件市场直接引入的,目前项目是uniapp编译成小程序开发及兼容H5端

@buuing
Copy link
Owner

buuing commented Dec 7, 2021

那你直接在插件里使用px单位的地方, 改成rpx试试, 我内部进行处理了

@My-Gao
Copy link
Author

My-Gao commented Dec 7, 2021

改成了rpx好像不生效... 直接有些地方背遮住了
微信图片_20211207143438

@buuing
Copy link
Owner

buuing commented Dec 7, 2021

我看看你代码怎么用的

@My-Gao
Copy link
Author

My-Gao commented Dec 7, 2021

我直接修改了上面的宽高,但是没有占满,是我哪里写错了吗..我对canvas不是很了解..
111
222

@buuing
Copy link
Owner

buuing commented Dec 7, 2021

????? 不要改我源码, 你在外面直接用就行了

我再重复一遍, 我不是反感别人改我代码, 你要是有能力hold得住, 你就改, 你别改完了, 还问我为啥你改的不对

@buuing
Copy link
Owner

buuing commented Dec 7, 2021

我真是服了, 这个包你不要动, 我里面的单位都是计算好的, 你在外面直接看文档使用就行

@My-Gao
Copy link
Author

My-Gao commented Dec 7, 2021

我错了大佬.. 我改回来了,我在外面改完了好像整体宽高是生效自适应了,但是blocks里面的padding属性我也用了rpx好像不支持?是只能用px吗?
111
222

@buuing
Copy link
Owner

buuing commented Dec 7, 2021

padding属性我好像忘记做适配了, 你先用px吧, 我下个版本增加一下padding响应式

@My-Gao
Copy link
Author

My-Gao commented Dec 7, 2021

好的,感谢大佬耐心解答!谢谢!

@buuing
Copy link
Owner

buuing commented Dec 7, 2021

没事, 用着顺手可以点个star支持一下

@My-Gao
Copy link
Author

My-Gao commented Dec 7, 2021

已经点了哦~非常好用!

@buuing buuing closed this as completed Dec 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants