Property mutation with simple components
See original GitHub issueVue.js version
2.0.0-rc.5
Reproduction Link
http://codepen.io/anon/pen/ORyJAa
Scenario
Most of our applications are build with a huge amount of backbone.js or marionette code. Especially for simple components like selects, search dropdowns or autogrowing textareas, the combination of our existing application stack and vuejs (1) components made ui development much more simple and consistent (and fun too).
For example: We’ve got complex form views (written in marionette), where you’ll find sth. like:
%form{ ... }
%our-input-component{ name: 'title', value: @title, large: 'true' }
%our-select{ name: 'gender', value: @gender }
%our-select-item{ value: 'f' } female
%our-select-item{ value: 'm' } male
By extending marionette just a little, it works pretty good currently. The marionette views are listening to the components to change (e.g. from the input or select) and then propagating those changes to models.
Problem
Now we’ve had a look on vuejs 2 (2.0.0-rc.4 and 2.0.0-rc.5).
Let’s take the select component example. The items were inserted through a slot. Clicking on an item will cause an event on the parent component. The select component manages it’s value based on those events.
With vuejs 2, can’t just change the value property due to the mutation warning:
[Vue warn]: Avoid mutating a prop directly since the value will be overwritten whenever the parent component re-renders. Instead, use a data or computed property based on the prop's value.
Question
Our implementations worked pretty much like polymer / webcomponents. With some marionette helpers, it was pretty simple to e.g. retrieve component attributes without knowing much internal stuff.
Now my question is, how those simple scenarios might be handled without maintaining some kind of global state or so?
Issue Analytics
- State:
- Created 7 years ago
- Comments:7 (4 by maintainers)
Top GitHub Comments
@wwlsascha the point is we don’t answer questions here - if we make an exception, then everyone will just start asking questions in issues.
@yyx990803 Just some minutes ago. But that’s not really the point. Can’t access the forum time to time and it’s hard to get help if not here…