Vue --- 面试题

1. Vue3 中的 setup() 和 Vue2 中的 data、methods 是什么关系?

  1. setup() 和 data、methods 是可以同时存在的, 但是不建议这样
  2. setup() 中定义好的数据和方法, 是可以 在 data 、methods 中使用 this.变量名 读取到的, 因为 setup() 的生命周期要早于 data、methods, 但是 data 、methods 中定义好的数据和方法, 是无法在 setup() 中 读取到的
  3. setup() 中的 this 的值是 undefined
posted @ 2024-08-08 17:22  河图s  阅读(9)  评论(0)    收藏  举报