0
Follow
2
View

vue3 reactive data failed, don't know what the problem is

ssxbg123 注册会员
2023-02-28 10:26

You used pagen.value ++ + to set the age property when you defined the obj object, which means that the age property will be initialized to -1, and when the code is finished, pageNum.value is also incremented by 1, but the age value has not changed, so it still shows -1. To solve this problem, you can change pagen.value ++ to pagen.value so that the age property is updated every time the name property is changed.

dxh8678 注册会员
2023-02-28 10:26
const obj = reactive(
{
name:'bajie',
age:pageNum
}
)

About the Author

Question Info

Publish Time
2023-02-28 10:26
Update Time
2023-02-28 10:26