useHash


追踪 location.hash 的变化

API

const { hash, setHash } = useHash()

Result

参数名描述类型
hash一个只读状态,对应当前 location.hash 的值DeepReadonly<Ref<string>>
setHash用于设置新的 hash(hash: string) => void

Example

Code

<template>
  <button @click="setHash('api')">set hash to params</button>
</template>

<script>
import { useHash } from 'vue-compositions'
export default {
  setup() {
    return useHash()
  }
}
</script>