How to pass a prop to a parent component in Vue.js












0















I am developing a Vue-Tac-Toe application just 4 fun and i am just stuck a bit now.



Please see screenshot first to understand the context.
vue-tac-toe stuck in logic





Problem: How can i pass the prop of cellRow to the component Field.vue?



What i want: Each Field should have a unique identification, for example the tile on the top left(first one) it should be recognized as cellRow: 0 & cellId: 0
because i need to have the information to simple check for a tic-tac-toe win(3 in a line etc.)





GameField.vue: We have a row and cell based layout.



<template>
<div id="game-field">
<div class="container">
<template v-for="(rows, index) in 3">
<Row :cell-row="index" />
</template>
</div>
</div>
</template>

<script>
import Row from './Row.vue';

export default {
components: {
Row,
},
data() {
return {};
},
};
</script>

<style lang="scss" scoped>
.container {
width: 400px;
margin: 10% auto 0;
}
</style>


Row.Vue: Each row got 3 Fields. from 0-2.



<template lang="html">
<div class="row">
<Field
v-for="(fieldId, index) in 3"
:key="fieldId"
:cell-id="index"
/>
</div>
</template>

<script>
import Field from './Field.vue';

export default {
components: {
Field,
},
props: {
cellRow: {
type: Number,
default: 0,
},
},
data() {
return {

};
},
};
</script>

<style lang="scss" scoped>
</style>


Field.vue:



<template lang="html">
<div class="cell">
<slot />
</div>
</template>

<script>
export default {
props: {
cellId: {
type: Number,
default: 0,
},
},
data() {
return {};
},
};
</script>

<style lang="scss" scoped>
.cell {
margin: 1px 3px -3px -1px;
width: 100px;
height: 100px;
background-color: white;
display: inline-block;
cursor: pointer;
}
</style>









share|improve this question





























    0















    I am developing a Vue-Tac-Toe application just 4 fun and i am just stuck a bit now.



    Please see screenshot first to understand the context.
    vue-tac-toe stuck in logic





    Problem: How can i pass the prop of cellRow to the component Field.vue?



    What i want: Each Field should have a unique identification, for example the tile on the top left(first one) it should be recognized as cellRow: 0 & cellId: 0
    because i need to have the information to simple check for a tic-tac-toe win(3 in a line etc.)





    GameField.vue: We have a row and cell based layout.



    <template>
    <div id="game-field">
    <div class="container">
    <template v-for="(rows, index) in 3">
    <Row :cell-row="index" />
    </template>
    </div>
    </div>
    </template>

    <script>
    import Row from './Row.vue';

    export default {
    components: {
    Row,
    },
    data() {
    return {};
    },
    };
    </script>

    <style lang="scss" scoped>
    .container {
    width: 400px;
    margin: 10% auto 0;
    }
    </style>


    Row.Vue: Each row got 3 Fields. from 0-2.



    <template lang="html">
    <div class="row">
    <Field
    v-for="(fieldId, index) in 3"
    :key="fieldId"
    :cell-id="index"
    />
    </div>
    </template>

    <script>
    import Field from './Field.vue';

    export default {
    components: {
    Field,
    },
    props: {
    cellRow: {
    type: Number,
    default: 0,
    },
    },
    data() {
    return {

    };
    },
    };
    </script>

    <style lang="scss" scoped>
    </style>


    Field.vue:



    <template lang="html">
    <div class="cell">
    <slot />
    </div>
    </template>

    <script>
    export default {
    props: {
    cellId: {
    type: Number,
    default: 0,
    },
    },
    data() {
    return {};
    },
    };
    </script>

    <style lang="scss" scoped>
    .cell {
    margin: 1px 3px -3px -1px;
    width: 100px;
    height: 100px;
    background-color: white;
    display: inline-block;
    cursor: pointer;
    }
    </style>









    share|improve this question



























      0












      0








      0








      I am developing a Vue-Tac-Toe application just 4 fun and i am just stuck a bit now.



      Please see screenshot first to understand the context.
      vue-tac-toe stuck in logic





      Problem: How can i pass the prop of cellRow to the component Field.vue?



      What i want: Each Field should have a unique identification, for example the tile on the top left(first one) it should be recognized as cellRow: 0 & cellId: 0
      because i need to have the information to simple check for a tic-tac-toe win(3 in a line etc.)





      GameField.vue: We have a row and cell based layout.



      <template>
      <div id="game-field">
      <div class="container">
      <template v-for="(rows, index) in 3">
      <Row :cell-row="index" />
      </template>
      </div>
      </div>
      </template>

      <script>
      import Row from './Row.vue';

      export default {
      components: {
      Row,
      },
      data() {
      return {};
      },
      };
      </script>

      <style lang="scss" scoped>
      .container {
      width: 400px;
      margin: 10% auto 0;
      }
      </style>


      Row.Vue: Each row got 3 Fields. from 0-2.



      <template lang="html">
      <div class="row">
      <Field
      v-for="(fieldId, index) in 3"
      :key="fieldId"
      :cell-id="index"
      />
      </div>
      </template>

      <script>
      import Field from './Field.vue';

      export default {
      components: {
      Field,
      },
      props: {
      cellRow: {
      type: Number,
      default: 0,
      },
      },
      data() {
      return {

      };
      },
      };
      </script>

      <style lang="scss" scoped>
      </style>


      Field.vue:



      <template lang="html">
      <div class="cell">
      <slot />
      </div>
      </template>

      <script>
      export default {
      props: {
      cellId: {
      type: Number,
      default: 0,
      },
      },
      data() {
      return {};
      },
      };
      </script>

      <style lang="scss" scoped>
      .cell {
      margin: 1px 3px -3px -1px;
      width: 100px;
      height: 100px;
      background-color: white;
      display: inline-block;
      cursor: pointer;
      }
      </style>









      share|improve this question
















      I am developing a Vue-Tac-Toe application just 4 fun and i am just stuck a bit now.



      Please see screenshot first to understand the context.
      vue-tac-toe stuck in logic





      Problem: How can i pass the prop of cellRow to the component Field.vue?



      What i want: Each Field should have a unique identification, for example the tile on the top left(first one) it should be recognized as cellRow: 0 & cellId: 0
      because i need to have the information to simple check for a tic-tac-toe win(3 in a line etc.)





      GameField.vue: We have a row and cell based layout.



      <template>
      <div id="game-field">
      <div class="container">
      <template v-for="(rows, index) in 3">
      <Row :cell-row="index" />
      </template>
      </div>
      </div>
      </template>

      <script>
      import Row from './Row.vue';

      export default {
      components: {
      Row,
      },
      data() {
      return {};
      },
      };
      </script>

      <style lang="scss" scoped>
      .container {
      width: 400px;
      margin: 10% auto 0;
      }
      </style>


      Row.Vue: Each row got 3 Fields. from 0-2.



      <template lang="html">
      <div class="row">
      <Field
      v-for="(fieldId, index) in 3"
      :key="fieldId"
      :cell-id="index"
      />
      </div>
      </template>

      <script>
      import Field from './Field.vue';

      export default {
      components: {
      Field,
      },
      props: {
      cellRow: {
      type: Number,
      default: 0,
      },
      },
      data() {
      return {

      };
      },
      };
      </script>

      <style lang="scss" scoped>
      </style>


      Field.vue:



      <template lang="html">
      <div class="cell">
      <slot />
      </div>
      </template>

      <script>
      export default {
      props: {
      cellId: {
      type: Number,
      default: 0,
      },
      },
      data() {
      return {};
      },
      };
      </script>

      <style lang="scss" scoped>
      .cell {
      margin: 1px 3px -3px -1px;
      width: 100px;
      height: 100px;
      background-color: white;
      display: inline-block;
      cursor: pointer;
      }
      </style>






      javascript vue.js tic-tac-toe






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Jan 20 at 11:45









      Erez Lieberman

      597522




      597522










      asked Jan 20 at 9:55









      DenizDeniz

      176




      176
























          1 Answer
          1






          active

          oldest

          votes


















          1














          If I understand the question correctly, you can pass cellRow prop of Row component further simply as a prop of Field component.



          Row (pass cellRow as a prop to Field)



          <template lang="html">
          <div class="row">
          <Field
          v-for="(fieldId, index) in 3"
          :key="fieldId"
          :cell-id="index"
          :row-id="cellRow" // passing row index to Field component
          />
          </div>
          </template>
          ...


          Field



          ...
          <script>
          export default {
          props: {
          cellId: {
          type: Number,
          default: 0,
          },
          rowId: { // defining new prop type
          type: Number,
          default: 0,
          },
          },
          ...
          };
          </script>


          Here is a little demo:






          Vue.config.devtools = false;
          Vue.config.productionTip = false;


          Vue.component('Row', {
          template:
          `
          <div class="row">
          <Field
          v-for="(fieldId, index) in 3"
          :key="fieldId"
          :cell-id="index"
          :row-id="cellRow"
          />
          </div>
          `,
          props: {
          cellRow: {
          type: Number,
          default: 0
          }
          }
          })

          Vue.component('Field', {
          template:
          `
          <div class="cell">
          <p>Row Id: {{ rowId }}</p>
          <p>Cell Id: {{ cellId }}</p>
          </div>
          `,
          props: {
          cellId: {
          type: Number,
          default: 0
          },
          rowId: {
          type: Number,
          default: 0
          }
          }
          })

          new Vue({
          el: '#demo',
          template:
          `
          <div id="game-field">
          <div class="container">
          <template v-for="(rows, index) in 3">
          <Row :cell-row="index" />
          </template>
          </div>
          </div>
          `
          })

          .cell {
          margin: 1px 3px 3px 1px;
          width: 100px;
          height: 100px;
          background-color: gray;
          display: inline-block;
          cursor: pointer;
          color: white;
          padding: 5px;
          }
          .container {
          width: 400px;
          margin: 10% auto 0;
          }

          <script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.17/vue.js"></script>
          <div id="demo"></div>








          share|improve this answer


























          • Are you not setting the prop new with this way? i need the value of row to be inside the Field.vue component. it needs to be related.

            – Deniz
            Jan 20 at 10:50






          • 1





            In this way new prop is created on a Field instance but the same value of a row index is being passed. Relations are preserved. I have updated the answer by adding a small demo, I hope it helps.

            – antonku
            Jan 20 at 11:19













          • very nice :) thank you

            – Deniz
            Jan 20 at 11:48











          • You are welcome :)

            – antonku
            Jan 20 at 15:08











          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54275285%2fhow-to-pass-a-prop-to-a-parent-component-in-vue-js%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          1














          If I understand the question correctly, you can pass cellRow prop of Row component further simply as a prop of Field component.



          Row (pass cellRow as a prop to Field)



          <template lang="html">
          <div class="row">
          <Field
          v-for="(fieldId, index) in 3"
          :key="fieldId"
          :cell-id="index"
          :row-id="cellRow" // passing row index to Field component
          />
          </div>
          </template>
          ...


          Field



          ...
          <script>
          export default {
          props: {
          cellId: {
          type: Number,
          default: 0,
          },
          rowId: { // defining new prop type
          type: Number,
          default: 0,
          },
          },
          ...
          };
          </script>


          Here is a little demo:






          Vue.config.devtools = false;
          Vue.config.productionTip = false;


          Vue.component('Row', {
          template:
          `
          <div class="row">
          <Field
          v-for="(fieldId, index) in 3"
          :key="fieldId"
          :cell-id="index"
          :row-id="cellRow"
          />
          </div>
          `,
          props: {
          cellRow: {
          type: Number,
          default: 0
          }
          }
          })

          Vue.component('Field', {
          template:
          `
          <div class="cell">
          <p>Row Id: {{ rowId }}</p>
          <p>Cell Id: {{ cellId }}</p>
          </div>
          `,
          props: {
          cellId: {
          type: Number,
          default: 0
          },
          rowId: {
          type: Number,
          default: 0
          }
          }
          })

          new Vue({
          el: '#demo',
          template:
          `
          <div id="game-field">
          <div class="container">
          <template v-for="(rows, index) in 3">
          <Row :cell-row="index" />
          </template>
          </div>
          </div>
          `
          })

          .cell {
          margin: 1px 3px 3px 1px;
          width: 100px;
          height: 100px;
          background-color: gray;
          display: inline-block;
          cursor: pointer;
          color: white;
          padding: 5px;
          }
          .container {
          width: 400px;
          margin: 10% auto 0;
          }

          <script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.17/vue.js"></script>
          <div id="demo"></div>








          share|improve this answer


























          • Are you not setting the prop new with this way? i need the value of row to be inside the Field.vue component. it needs to be related.

            – Deniz
            Jan 20 at 10:50






          • 1





            In this way new prop is created on a Field instance but the same value of a row index is being passed. Relations are preserved. I have updated the answer by adding a small demo, I hope it helps.

            – antonku
            Jan 20 at 11:19













          • very nice :) thank you

            – Deniz
            Jan 20 at 11:48











          • You are welcome :)

            – antonku
            Jan 20 at 15:08
















          1














          If I understand the question correctly, you can pass cellRow prop of Row component further simply as a prop of Field component.



          Row (pass cellRow as a prop to Field)



          <template lang="html">
          <div class="row">
          <Field
          v-for="(fieldId, index) in 3"
          :key="fieldId"
          :cell-id="index"
          :row-id="cellRow" // passing row index to Field component
          />
          </div>
          </template>
          ...


          Field



          ...
          <script>
          export default {
          props: {
          cellId: {
          type: Number,
          default: 0,
          },
          rowId: { // defining new prop type
          type: Number,
          default: 0,
          },
          },
          ...
          };
          </script>


          Here is a little demo:






          Vue.config.devtools = false;
          Vue.config.productionTip = false;


          Vue.component('Row', {
          template:
          `
          <div class="row">
          <Field
          v-for="(fieldId, index) in 3"
          :key="fieldId"
          :cell-id="index"
          :row-id="cellRow"
          />
          </div>
          `,
          props: {
          cellRow: {
          type: Number,
          default: 0
          }
          }
          })

          Vue.component('Field', {
          template:
          `
          <div class="cell">
          <p>Row Id: {{ rowId }}</p>
          <p>Cell Id: {{ cellId }}</p>
          </div>
          `,
          props: {
          cellId: {
          type: Number,
          default: 0
          },
          rowId: {
          type: Number,
          default: 0
          }
          }
          })

          new Vue({
          el: '#demo',
          template:
          `
          <div id="game-field">
          <div class="container">
          <template v-for="(rows, index) in 3">
          <Row :cell-row="index" />
          </template>
          </div>
          </div>
          `
          })

          .cell {
          margin: 1px 3px 3px 1px;
          width: 100px;
          height: 100px;
          background-color: gray;
          display: inline-block;
          cursor: pointer;
          color: white;
          padding: 5px;
          }
          .container {
          width: 400px;
          margin: 10% auto 0;
          }

          <script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.17/vue.js"></script>
          <div id="demo"></div>








          share|improve this answer


























          • Are you not setting the prop new with this way? i need the value of row to be inside the Field.vue component. it needs to be related.

            – Deniz
            Jan 20 at 10:50






          • 1





            In this way new prop is created on a Field instance but the same value of a row index is being passed. Relations are preserved. I have updated the answer by adding a small demo, I hope it helps.

            – antonku
            Jan 20 at 11:19













          • very nice :) thank you

            – Deniz
            Jan 20 at 11:48











          • You are welcome :)

            – antonku
            Jan 20 at 15:08














          1












          1








          1







          If I understand the question correctly, you can pass cellRow prop of Row component further simply as a prop of Field component.



          Row (pass cellRow as a prop to Field)



          <template lang="html">
          <div class="row">
          <Field
          v-for="(fieldId, index) in 3"
          :key="fieldId"
          :cell-id="index"
          :row-id="cellRow" // passing row index to Field component
          />
          </div>
          </template>
          ...


          Field



          ...
          <script>
          export default {
          props: {
          cellId: {
          type: Number,
          default: 0,
          },
          rowId: { // defining new prop type
          type: Number,
          default: 0,
          },
          },
          ...
          };
          </script>


          Here is a little demo:






          Vue.config.devtools = false;
          Vue.config.productionTip = false;


          Vue.component('Row', {
          template:
          `
          <div class="row">
          <Field
          v-for="(fieldId, index) in 3"
          :key="fieldId"
          :cell-id="index"
          :row-id="cellRow"
          />
          </div>
          `,
          props: {
          cellRow: {
          type: Number,
          default: 0
          }
          }
          })

          Vue.component('Field', {
          template:
          `
          <div class="cell">
          <p>Row Id: {{ rowId }}</p>
          <p>Cell Id: {{ cellId }}</p>
          </div>
          `,
          props: {
          cellId: {
          type: Number,
          default: 0
          },
          rowId: {
          type: Number,
          default: 0
          }
          }
          })

          new Vue({
          el: '#demo',
          template:
          `
          <div id="game-field">
          <div class="container">
          <template v-for="(rows, index) in 3">
          <Row :cell-row="index" />
          </template>
          </div>
          </div>
          `
          })

          .cell {
          margin: 1px 3px 3px 1px;
          width: 100px;
          height: 100px;
          background-color: gray;
          display: inline-block;
          cursor: pointer;
          color: white;
          padding: 5px;
          }
          .container {
          width: 400px;
          margin: 10% auto 0;
          }

          <script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.17/vue.js"></script>
          <div id="demo"></div>








          share|improve this answer















          If I understand the question correctly, you can pass cellRow prop of Row component further simply as a prop of Field component.



          Row (pass cellRow as a prop to Field)



          <template lang="html">
          <div class="row">
          <Field
          v-for="(fieldId, index) in 3"
          :key="fieldId"
          :cell-id="index"
          :row-id="cellRow" // passing row index to Field component
          />
          </div>
          </template>
          ...


          Field



          ...
          <script>
          export default {
          props: {
          cellId: {
          type: Number,
          default: 0,
          },
          rowId: { // defining new prop type
          type: Number,
          default: 0,
          },
          },
          ...
          };
          </script>


          Here is a little demo:






          Vue.config.devtools = false;
          Vue.config.productionTip = false;


          Vue.component('Row', {
          template:
          `
          <div class="row">
          <Field
          v-for="(fieldId, index) in 3"
          :key="fieldId"
          :cell-id="index"
          :row-id="cellRow"
          />
          </div>
          `,
          props: {
          cellRow: {
          type: Number,
          default: 0
          }
          }
          })

          Vue.component('Field', {
          template:
          `
          <div class="cell">
          <p>Row Id: {{ rowId }}</p>
          <p>Cell Id: {{ cellId }}</p>
          </div>
          `,
          props: {
          cellId: {
          type: Number,
          default: 0
          },
          rowId: {
          type: Number,
          default: 0
          }
          }
          })

          new Vue({
          el: '#demo',
          template:
          `
          <div id="game-field">
          <div class="container">
          <template v-for="(rows, index) in 3">
          <Row :cell-row="index" />
          </template>
          </div>
          </div>
          `
          })

          .cell {
          margin: 1px 3px 3px 1px;
          width: 100px;
          height: 100px;
          background-color: gray;
          display: inline-block;
          cursor: pointer;
          color: white;
          padding: 5px;
          }
          .container {
          width: 400px;
          margin: 10% auto 0;
          }

          <script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.17/vue.js"></script>
          <div id="demo"></div>








          Vue.config.devtools = false;
          Vue.config.productionTip = false;


          Vue.component('Row', {
          template:
          `
          <div class="row">
          <Field
          v-for="(fieldId, index) in 3"
          :key="fieldId"
          :cell-id="index"
          :row-id="cellRow"
          />
          </div>
          `,
          props: {
          cellRow: {
          type: Number,
          default: 0
          }
          }
          })

          Vue.component('Field', {
          template:
          `
          <div class="cell">
          <p>Row Id: {{ rowId }}</p>
          <p>Cell Id: {{ cellId }}</p>
          </div>
          `,
          props: {
          cellId: {
          type: Number,
          default: 0
          },
          rowId: {
          type: Number,
          default: 0
          }
          }
          })

          new Vue({
          el: '#demo',
          template:
          `
          <div id="game-field">
          <div class="container">
          <template v-for="(rows, index) in 3">
          <Row :cell-row="index" />
          </template>
          </div>
          </div>
          `
          })

          .cell {
          margin: 1px 3px 3px 1px;
          width: 100px;
          height: 100px;
          background-color: gray;
          display: inline-block;
          cursor: pointer;
          color: white;
          padding: 5px;
          }
          .container {
          width: 400px;
          margin: 10% auto 0;
          }

          <script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.17/vue.js"></script>
          <div id="demo"></div>





          Vue.config.devtools = false;
          Vue.config.productionTip = false;


          Vue.component('Row', {
          template:
          `
          <div class="row">
          <Field
          v-for="(fieldId, index) in 3"
          :key="fieldId"
          :cell-id="index"
          :row-id="cellRow"
          />
          </div>
          `,
          props: {
          cellRow: {
          type: Number,
          default: 0
          }
          }
          })

          Vue.component('Field', {
          template:
          `
          <div class="cell">
          <p>Row Id: {{ rowId }}</p>
          <p>Cell Id: {{ cellId }}</p>
          </div>
          `,
          props: {
          cellId: {
          type: Number,
          default: 0
          },
          rowId: {
          type: Number,
          default: 0
          }
          }
          })

          new Vue({
          el: '#demo',
          template:
          `
          <div id="game-field">
          <div class="container">
          <template v-for="(rows, index) in 3">
          <Row :cell-row="index" />
          </template>
          </div>
          </div>
          `
          })

          .cell {
          margin: 1px 3px 3px 1px;
          width: 100px;
          height: 100px;
          background-color: gray;
          display: inline-block;
          cursor: pointer;
          color: white;
          padding: 5px;
          }
          .container {
          width: 400px;
          margin: 10% auto 0;
          }

          <script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.17/vue.js"></script>
          <div id="demo"></div>






          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Jan 20 at 11:15

























          answered Jan 20 at 10:39









          antonkuantonku

          1,132137




          1,132137













          • Are you not setting the prop new with this way? i need the value of row to be inside the Field.vue component. it needs to be related.

            – Deniz
            Jan 20 at 10:50






          • 1





            In this way new prop is created on a Field instance but the same value of a row index is being passed. Relations are preserved. I have updated the answer by adding a small demo, I hope it helps.

            – antonku
            Jan 20 at 11:19













          • very nice :) thank you

            – Deniz
            Jan 20 at 11:48











          • You are welcome :)

            – antonku
            Jan 20 at 15:08



















          • Are you not setting the prop new with this way? i need the value of row to be inside the Field.vue component. it needs to be related.

            – Deniz
            Jan 20 at 10:50






          • 1





            In this way new prop is created on a Field instance but the same value of a row index is being passed. Relations are preserved. I have updated the answer by adding a small demo, I hope it helps.

            – antonku
            Jan 20 at 11:19













          • very nice :) thank you

            – Deniz
            Jan 20 at 11:48











          • You are welcome :)

            – antonku
            Jan 20 at 15:08

















          Are you not setting the prop new with this way? i need the value of row to be inside the Field.vue component. it needs to be related.

          – Deniz
          Jan 20 at 10:50





          Are you not setting the prop new with this way? i need the value of row to be inside the Field.vue component. it needs to be related.

          – Deniz
          Jan 20 at 10:50




          1




          1





          In this way new prop is created on a Field instance but the same value of a row index is being passed. Relations are preserved. I have updated the answer by adding a small demo, I hope it helps.

          – antonku
          Jan 20 at 11:19







          In this way new prop is created on a Field instance but the same value of a row index is being passed. Relations are preserved. I have updated the answer by adding a small demo, I hope it helps.

          – antonku
          Jan 20 at 11:19















          very nice :) thank you

          – Deniz
          Jan 20 at 11:48





          very nice :) thank you

          – Deniz
          Jan 20 at 11:48













          You are welcome :)

          – antonku
          Jan 20 at 15:08





          You are welcome :)

          – antonku
          Jan 20 at 15:08




















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54275285%2fhow-to-pass-a-prop-to-a-parent-component-in-vue-js%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Homophylophilia

          Updating UILabel text programmatically using a function

          Cloud Functions - OpenCV Videocapture Read method fails for larger files from cloud storage