@uni-use/supported
v1.5.1
Published
SSR compatibility isSupported
Downloads
4
Maintainers
Readme
@uni-use/supported
A combined api for SSR compatibility isSupported
Installing
# use pnpm
$ pnpm install @uni-use/supported
# use npm
$ npm install @uni-use/supported --save
# use yarn
$ yarn add @uni-use/supported
Usage
1. Using in vue3.x:
<script setup>
import useSupported from '@uni-use/supported'
const isSupported = useSupported(() => navigator && 'getBattery' in navigator)
if (isSupported.value) {
// do something
navigator.getBattery
}
defineExpose({
isSupported
})
</script>
2. Using in vue2.7.x:
<script>
import useSupported from '@uni-use/supported'
export default {
setup() {
const isSupported = useSupported(() => navigator && 'getBattery' in navigator)
if (isSupported.value) {
// do something
navigator.getBattery
}
return {
isSupported
}
}
}
</script>
3. Use CDN resource
<script src="https://unpkg.com/vue-demi@latest/lib/index.iife.js"></script>
<script src="https://unpkg.com/@uni-use/[email protected]/dist/index.global.prod.js"></script>
<script>
const supported = useSupported(() => navigator && 'getBattery' in navigator)
// ...
</script>
Support & Issues
Please open an issue here.