子组件可以用
const { foo = 'hello' } = defineProps<{ foo?: string }>()
const { foo = 'hello' } = defineProps<{ foo?: string }>()

1 leoQaQ 1 day ago 3.4 及以前,解构写法会失去响应式,之前一个项目一直 watch 不到 props ,找了好久,原来是这个问题。后面的项目都是 3.5 了,不存在这个问题了 |
2 lujiaosama 1 day ago 这个不错,不用一直.点了。 |
4 crocoBaby OP @lujiaosama 被响应式和默认值的 props 恶心太久了 |
5 Ketteiron 1 day ago 当我们说 xxx 更新时,一般是前几天或者前几周发布的更新吧? 而不是标记为稳定特性接近两年,作为实验性特性超过五年的“更新”吧? |
6 MzM2ODkx 1 day ago 这不好久的事了吗 |
7 lscho 1 day ago 刚才点进来我都不敢回复,以为我记错了。。。这个特性很久了 |
10 SunShare 1 day ago 额~咱们线对齐一下信息(点进来之前还以为发布 Vapor ) 3.5+确实已经默认支持 propsDestructure https://blog.vuejs.org/posts/vue-3-5#reactive-props-destructure 不过看社区对此有过激烈讨论 https://github.com/vuejs/rfcs/discussions/502 |
12 lightyisu 1 day ago 几个月前看官网就有这个解构不掉响应式的案例了 |
13 K332 1 day ago 就是 withDefaults 的优化,但是我记得去年就看到这个优化了 |
14 Ketteiron 1 day ago @crocoBaby #8 3.2 可以改配置开启实验性特性,3.3 废除,要装 macros 才能继续用,3.5 重新加回来并默认开启。 https://github.com/vuejs/rfcs/discussions/369 https://github.com/vuejs/rfcs/discussions/413 https://github.com/vuejs/rfcs/discussions/502 另外我记错了年份,作为实验性特性加入 vue 代码库是四年前的事,当时这个都快讨论烂了。 |
15 gpt5 1 day ago 虽然但是,这东西有中国背景,不敢用啊。 |
16 liuxue 1 day ago 我现在还在用 node16 + vue2…… |
17 Sh15 PRO |
21 94 1 day ago |
22 dbskcnc 1 day ago 我还以为是说 3.6 放出来了,就这 |
23 lixon166 1 day ago 说来惭愧 vibe 完几个 vue 项目 还不懂语法 |
24 dcatfly 1 day ago |
25 BaiLinfeng 1 day ago 好久没有写了,都忘记怎么写的了 |
26 kneo 1 day ago vue 3 确实是个史诗级更新 |
28 Rust2015 3h 31m ago 这个帖子,你可以搜索一下,去年好像讲过这个 API |