Skip to content
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

v-model binding with array. (fix #3958,#3979) #3988

Merged
merged 5 commits into from Oct 22, 2016
Merged

v-model binding with array. (fix #3958,#3979) #3988

merged 5 commits into from Oct 22, 2016

Conversation

defcc
Copy link
Member

@defcc defcc commented Oct 20, 2016

fix #3958 #3979
As for array type case, v-model="model[idx]" binding uses model[idx]= internally, so the value change could not be reactive.

the binding model expression maybe be as follows:

  • test
  • test[idx]
  • test[test1[idx]]
  • xxx.test[a[a].test1[idx]]
  • test.xxx.a["asa"][test1[idx]]
  • test["a"][idx]

So I use a modelParser to parse the model expression to two parts exp and idx, and if the exp is an Array type, then use $$exp.splice($$idx, 1, value)

@yyx990803 yyx990803 merged commit 3105661 into vuejs:dev Oct 22, 2016
@yyx990803
Copy link
Member

Beautifully done! 💯

@sqal sqal mentioned this pull request Nov 1, 2016
@blade254353074
Copy link

blade254353074 commented Nov 15, 2016

@defcc @yyx990803

What about test[index].key?
test: [{ key: 'value' }]

https://jsbin.com/medatifajo/1/edit?html,js,output

@defcc
Copy link
Member Author

defcc commented Nov 16, 2016

already fixed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

vue 2.0.3 v-model not updating using an array
3 participants