usePrevious
usePrevious
refの前の値を保持します。
使用法
import { usePrevious } from '@vueuse/core'
import { shallowRef } from 'vue'
const counter = shallowRef('Hello')
const previous = usePrevious(counter)
console.log(previous.value) // undefined
counter.value = 'World'
console.log(previous.value) // Hello
© 2019–PRESENT Anthony Fu https://github.com/antfu
※このページは Nuxt.js 公式ドキュメントの翻訳ページです。
公式ドキュメントの該当ページはこちら:
#