Skip to content

Instantly share code, notes, and snippets.

@ThaddeusJiang
Created November 24, 2020 03:36
Show Gist options
  • Save ThaddeusJiang/6083febf0f07c4b7c9fe7a16b5d5a148 to your computer and use it in GitHub Desktop.
Save ThaddeusJiang/6083febf0f07c4b7c9fe7a16b5d5a148 to your computer and use it in GitHub Desktop.
Vue setup 然而不要解构 props 对象,那样会使其失去响应性:

然而不要解构 props 对象,那样会使其失去响应性:

export default {
  props: {
    name: String,
  },
  setup({ name }) {
    watchEffect(() => {
      console.log(`name is: ` + name) // Will not be reactive!
    })
  },
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment