Skip to main content
Code Review

Return to Answer

replaced https://vuejs.org/v2 with https://v2.vuejs.org/v2
Source Link
  1. Add applicant via the the local data properties:

     data: function() {
     return {
     applicant: {}
     }
     },
    
  2. When the component is created, set the applicant to the value property:

     created: function() {
     this.applicant = this.value;
     }
    
  3. Watch for changes on the local data property applicant and emit emit an event in response to that change

     watch: {
     'applicant': function() {
     // When the internal value changes, we $emit an event. Because this event is 
     // named 'input', v-model will automatically update the parent value
     this.$emit('applicant', this.applicant);
     }
     }
    
  1. Add applicant via the the local data properties:

     data: function() {
     return {
     applicant: {}
     }
     },
    
  2. When the component is created, set the applicant to the value property:

     created: function() {
     this.applicant = this.value;
     }
    
  3. Watch for changes on the local data property applicant and emit an event in response to that change

     watch: {
     'applicant': function() {
     // When the internal value changes, we $emit an event. Because this event is 
     // named 'input', v-model will automatically update the parent value
     this.$emit('applicant', this.applicant);
     }
     }
    
  1. Add applicant via the the local data properties:

     data: function() {
     return {
     applicant: {}
     }
     },
    
  2. When the component is created, set the applicant to the value property:

     created: function() {
     this.applicant = this.value;
     }
    
  3. Watch for changes on the local data property applicant and emit an event in response to that change

     watch: {
     'applicant': function() {
     // When the internal value changes, we $emit an event. Because this event is 
     // named 'input', v-model will automatically update the parent value
     this.$emit('applicant', this.applicant);
     }
     }
    
fix typos
Source Link

Doesn’tDoesn't it seem a bit redundant to have a compnentcomponent called applicant, which has a property called applicant? Perhaps a more generic name for those properties would be more appropriate - e.g. attributes. However, the advice below, which responds to your question, suggests binding the applicant to the model attribute instead of a property.

Doesn’t it seem a bit redundant to have a compnent called applicant, which has a property called applicant? Perhaps a more generic name for those properties would be more appropriate - e.g. attributes. However, the advice below, which responds to your question, suggests binding the applicant to the model attribute instead of a property.

Doesn't it seem a bit redundant to have a component called applicant, which has a property called applicant? Perhaps a more generic name for those properties would be more appropriate - e.g. attributes. However, the advice below, which responds to your question, suggests binding the applicant to the model attribute instead of a property.

added 829 characters in body
Source Link

##General feedback The use of the <script> tag as a template is nice and I have aimed to use that more frequently in my own projects when not using a larger template library.

Doesn’t it seem a bit redundant to have a compnent called applicant, which has a property called applicant? Perhaps a more generic name for those properties would be more appropriate - e.g. attributes. However, the advice below, which responds to your question, suggests binding the applicant to the model attribute instead of a property.

##Main question

Since I'm passing the parent applicant object to the component and am modifying it directly through that passed in reference using the v-model directive am I not directly modifying the parent object so therefore keeping the data coupled as the docs recommended against.

Your question appears nearly identical to this SO question, though in your case you have working code and are passing an object instead of a single value. To follow the guidelines in the documentation, perhaps altering the code as described in the answer by asemahle would be an optimal route.

Your question appears nearly identical to this SO question, though in your case you have working code and are passing an object instead of a single value. To follow the guidelines in the documentation, perhaps altering the code as described in the answer by asemahle would be an optimal route.

##General feedback The use of the <script> tag as a template is nice and I have aimed to use that more frequently in my own projects when not using a larger template library.

Doesn’t it seem a bit redundant to have a compnent called applicant, which has a property called applicant? Perhaps a more generic name for those properties would be more appropriate - e.g. attributes. However, the advice below, which responds to your question, suggests binding the applicant to the model attribute instead of a property.

##Main question

Since I'm passing the parent applicant object to the component and am modifying it directly through that passed in reference using the v-model directive am I not directly modifying the parent object so therefore keeping the data coupled as the docs recommended against.

Your question appears nearly identical to this SO question, though in your case you have working code and are passing an object instead of a single value. To follow the guidelines in the documentation, perhaps altering the code as described in the answer by asemahle would be an optimal route.

added 180 characters in body
Source Link
Loading
added 61 characters in body
Source Link
Loading
Source Link
Loading
lang-js

AltStyle によって変換されたページ (->オリジナル) /