useMap
一个可以管理 Map 类型状态的 Hook。
使用Demo
<template>
<div class="hello">
<div>
<p> value:{{ state }}</p>
<button @click="()=> set('1',Math.random())">set</button>
<button @click="()=> remove('1')">remove</button>
<button @click="()=> setAll([ ['1','111'], ['2','2222'] ])">setAll</button>
</div>
</div>
</template>
<script lang="ts">
import { useMap } from "v3hooks";
export default {
props: {
msg: String,
},
setup() {
const [state, { set, setAll, remove }] = useMap([
['1','321']
]);
return {
state,
set,
setAll,
remove
};
},
};
</script>Api
Params
Result
最后更新于