mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-05 05:42:44 +08:00
docs(Uploader): add FAQ about camera permission (#12289)
This commit is contained in:
parent
78e4174a30
commit
534ccd2b3a
@ -452,3 +452,24 @@ The component provides the following CSS variables, which can be used to customi
|
||||
| --van-uploader-loading-icon-color | _var(--van-white)_ | - |
|
||||
| --van-uploader-disabled-opacity | _var(--van-disabled-opacity)_ | - |
|
||||
| --van-uploader-border-radius | _0px_ | - |
|
||||
|
||||
## FAQ
|
||||
|
||||
### How do I know if the user has granted camera permission?
|
||||
|
||||
When uploading an image, if the user has not granted camera permission to the current app, the Uploader component will not work.
|
||||
|
||||
You can determine if camera permission has been granted by using the [getUserMedia](https://developer.mozilla.org/en-US/docs/Web/API/MediaDevices/getUserMedia) method provided by the browser (please note that the `getUserMedia` method cannot be used in iOS 10).
|
||||
|
||||
Here is a simplified example:
|
||||
|
||||
```ts
|
||||
navigator.mediaDevices
|
||||
.getUserMedia({ video: true })
|
||||
.then((stream) => {
|
||||
console.log(stream);
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log(err);
|
||||
});
|
||||
```
|
||||
|
@ -535,3 +535,22 @@ export default {
|
||||
目前 Chrome、Safari 等浏览器不支持展示 HEIC/HEIF 格式的图片,因此上传后无法在 Uploader 组件中进行预览。
|
||||
|
||||
[HEIF] 格式的兼容性请参考 [caniuse](https://caniuse.com/?search=heic)。
|
||||
|
||||
### 如何判断用户授予了摄像头权限?
|
||||
|
||||
在上传图片时,如果用户没有授予当前 App 摄像头权限,会导致 Uploader 组件无法使用。
|
||||
|
||||
你可以通过浏览器提供的 [getUserMedia](https://developer.mozilla.org/zh-CN/docs/Web/API/MediaDevices/getUserMedia) 方法来判断是否被授予了摄像头权限(请留意 `getUserMedia` 方法无法在 iOS 10 中使用)。
|
||||
|
||||
以下是一个简化的示例:
|
||||
|
||||
```ts
|
||||
navigator.mediaDevices
|
||||
.getUserMedia({ video: true })
|
||||
.then((stream) => {
|
||||
console.log(stream);
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log(err);
|
||||
});
|
||||
```
|
||||
|
Loading…
x
Reference in New Issue
Block a user