v-bind没有响应式
Vue version
vue3
Link to minimal reproduction
Steps to reproduce
1
2
What is expected?
有响应式
What is actually happening?
无响应式
System Info
No response
Any additional comments?
No response
再看一个有意思的问题, 给div加了一个@click就变成响应式了,请看代码(点击button 点击div3 div1和div3都有响应式,div2依然没有) https://sfc.vuejs.org/#eNp9kk1u2zAQha8yIAo4QWMxbtGNKhvtPbiILI0lJhZJkCMlhaEL9BBF0UWXPUCBHsf36OjPUeIkXEjk8M3HmUcexFfnoqZGEYuEsHL7lHCjDPBItjWRNfAl2+vsbq0EYSAlNsdfP47ffx7//Dv+/Z3IQTSl5LqBONC3PbI+s2ani6hfct4g6WXlarNKJH/HNMl5p1O9nNOa5Vab/EQ743x4jfNi8lkzT2EfX4AlcuYLL0PmtSMISLUbpbpy1hMcwGOakW4QWth5W8GCnV187tI62R4J7nVOJaxhdX3N8Sk6lMfhCXBxeCys9y+GWaQbPSiGm3eHfta6h5urp4oSdVFSDAs+yz0snu1u0+yu8LY2OSusT02Bc0k7ztvLWZmdZ1zkxSWsN/N6hqber+HT1FQ35tcfTX3P6x21Lf8TOdjKhoorMfi5rFIX3QZr+G32h6lxIyhxskMJtrhbK1ESuRBLGXZZ96JvQ2R9IXkW+dqQrjDCUC233t4H9AxWYuyxZ0gONuiXHk2OHv1bzGfSM26HbZVpRfsf3ZkOoA==
分析了一下
export function guardReactiveProps(props: (Data & VNodeProps) | null) {
if (!props) return null
return isProxy(props) || InternalObjectKey in props
? extend({}, props)
: props
}
似乎是这里的浅拷贝导致当你修改witdh,dynamicChildren中的旧props也改变了,这样在patchProps时就没有重新渲染
It seems that the shallow copy here causes the old props
in dynamicchildren to change when you modify the width
, so there is no re rendering when patchprops