-
Notifications
You must be signed in to change notification settings - Fork 3.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
api doc: explicitly tell set
only works when the prop doesn't exist yet
#1601
Comments
Set should also work with a property that already exists, like here - it's just not necessary. Could you provide a pen/fiddle demonstrating the situation you found where it doesn't work? |
@chrisvfritz Here we go. I'm not entirely clear in the first post, edited it, try read again. |
Ah, I see the issue here. It's:
The reason
To me, that already specifies that On a related note, it's bad practice to add new root properties to
|
Of the phrasing, I'm not sure, I'm Chinese and your name suggests you're a native English speaker so... I feel: "created", can I recreated it with $set? Because I don't need view update when the prop is added, but do when I used $set. "cannot detect addition", sure, can I make up for it using $set after addition? Feels somehow vague, but I'm not sure if it's necessary to stress using $set later won't help. Maybe we should wait for someone else's opinion. Not declaring in |
Hm, what would you think about this rewording?
|
I think this is more clear if anyone has the same doubt as me:
Somehow I feel this behavior itself is not intuitive. I've opened an issue for vue, let's see what people say about that then. |
Excellent! I just made that update to the docs. I also left a comment on your issue. I don't think |
Note: Here I'm all talking about a prop that doesn't exist in
data
in the first place.The api says:
At least for me, it's not clear "does
set
work if the prop isn't indata
, and I've already added it diredtly withoutset
?". So I tried the source code and the comment made it clear:Then I altered my code to use
set
at prop addition and the not-properly-re-rendering problem was fixed.So I think it may be better to explicitly tell in the api that
set
only works when the prop doesn't exist yet? Like the comment does?The text was updated successfully, but these errors were encountered: