Vue 重置 data 数据

Vue About 294 words

Vue2

this.$data = this.$options.data()

Object.assign(this.$data, this.$options.data())

Vue3

setup () {
  const initState = () => {
    return {
      name: 'Jason'
    }
  }

  const state = reactive(initState())

  const resetState = () => {
    Object.assign(state, initState())
  }
}
Views: 1,450 · Posted: 2023-01-13

————        END        ————

Give me a Star, Thanks:)

https://github.com/fendoudebb/LiteNote

扫描下方二维码关注公众号和小程序↓↓↓

扫描下方二维码关注公众号和小程序↓↓↓


Today On History
Browsing Refresh