useCookie
一个用来操作Cookie的 Hook 。
使用Demo
<template>
<div class="hello" style="display:flex;align-items:flex-start;">
<p> value:{{ state }}</p>
<button @click="handlerUpdateState">修改Cookie</button>
</div>
</template>
<script lang="ts">
import { useCookie } from "v3hooks";
export default {
props: {
msg: String,
},
setup() {
// 获取cookie中的a
const state = useCookie('a',{
defaultValue: '1111',
watch: true,
path: '/useCookie',
expires: 1,
});
const handlerUpdateState = ()=>{
state.value = String( Math.random() );
};
// useVirtualList测试
return {
state,
handlerUpdateState
};
},
};
</script>注意点
Api
Params
Result
Options
最后更新于