主题
useFavicon
反应式图标
🌐 Reactive favicon
示例
用法
🌐 Usage
ts
import { useFavicon } from '@vueuse/core'
const icon = useFavicon()
icon.value = 'dark.png' // change current icon传递源引用
🌐 Passing a source ref
你可以传入一个 ref,源引用的更改会自动反映到你的网站图标上。
🌐 You can pass a ref to it, changes from of the source ref will be reflected to your favicon automatically.
ts
import { useFavicon, usePreferredDark } from '@vueuse/core'
import { computed } from 'vue'
const isDark = usePreferredDark()
const favicon = computed(() => isDark.value ? 'dark.png' : 'light.png')
useFavicon(favicon)当传递源引用时,返回引用将与源引用相同
🌐 When a source ref is passed, the return ref will be identical to the source ref
ts
const source = shallowRef('icon.png')
const icon = useFavicon(source)
console.log(icon === source) // true