Vuejs - Cannot access array element using v-for in child component









up vote
0
down vote

favorite












I'm passing an array from a parent component to a child. The array is being passed and I can access the entire array, but for some reason when I try and access on array element I can't.



(This is shortened for brevity's sake)



When I do this:



<template v-for="creds in amazonCredsArray">
<v-container fluid grid-list-lg class="come_closer">
<v-layout row wrap>
<v-flex xs12>
<v-card class="lightpurple">
<v-card-title>
<v-icon class="my_dark_purple_text">language</v-icon>
<h1 class="title oswald my_dark_purple_text pl-2 pr-5">ENTER YOUR AMAZON CREDENTIALS BELOW</h1>
</v-card-title>
<v-form ref="form" v-model="valid">
<h1>amazonCredsArray</h1>


I can see the amazonCredsArray displayed.. it looks like this:



[ "auth_token": "amzn.mws.9cb254dXXXXX", "seller_id": "CXDFDFDF", "marketplace": "asdfasdfasdf", "zones": [ "name": "United States", "id": 1 ] , "auth_token": "asjdfljakldfjlsadf", "seller_id": "ddeeee", "marketplace": "12", "zones": [ "name": "United States", "id": 1 ] ]


However when I try to use creds in that same place in the view, I don't get anything. I'm trying this:



<template v-for="creds in amazonCredsArray">
<v-container fluid grid-list-lg class="come_closer">
<v-layout row wrap>
<v-flex xs12>
<v-card class="lightpurple">
<v-card-title>
<v-icon class="my_dark_purple_text">language</v-icon>
<h1 class="title oswald my_dark_purple_text pl-2 pr-5">ENTER YOUR AMAZON CREDENTIALS BELOW</h1>
</v-card-title>
<v-form ref="form" v-model="valid">
<h1>creds</h1>









share|improve this question





















  • maybe its because your using v-for directive on the root tag. (<template>). its forbidden in vuejs. try wrapping your content in one root element. it should help.
    – Efrat
    Nov 10 at 22:16










  • Great thanks.. heck I'll try anything
    – ToddT
    Nov 10 at 23:00










  • @Elfrat, root tag(template) can be used with v-for for iteration (vuejs.org/v2/guide/list.html#v-for-on-a-lt-template-gt). Toddt, I created a codepen and it appears to work well. Something else may be blocking or causing the issue
    – nara_l
    Nov 11 at 2:31














up vote
0
down vote

favorite












I'm passing an array from a parent component to a child. The array is being passed and I can access the entire array, but for some reason when I try and access on array element I can't.



(This is shortened for brevity's sake)



When I do this:



<template v-for="creds in amazonCredsArray">
<v-container fluid grid-list-lg class="come_closer">
<v-layout row wrap>
<v-flex xs12>
<v-card class="lightpurple">
<v-card-title>
<v-icon class="my_dark_purple_text">language</v-icon>
<h1 class="title oswald my_dark_purple_text pl-2 pr-5">ENTER YOUR AMAZON CREDENTIALS BELOW</h1>
</v-card-title>
<v-form ref="form" v-model="valid">
<h1>amazonCredsArray</h1>


I can see the amazonCredsArray displayed.. it looks like this:



[ "auth_token": "amzn.mws.9cb254dXXXXX", "seller_id": "CXDFDFDF", "marketplace": "asdfasdfasdf", "zones": [ "name": "United States", "id": 1 ] , "auth_token": "asjdfljakldfjlsadf", "seller_id": "ddeeee", "marketplace": "12", "zones": [ "name": "United States", "id": 1 ] ]


However when I try to use creds in that same place in the view, I don't get anything. I'm trying this:



<template v-for="creds in amazonCredsArray">
<v-container fluid grid-list-lg class="come_closer">
<v-layout row wrap>
<v-flex xs12>
<v-card class="lightpurple">
<v-card-title>
<v-icon class="my_dark_purple_text">language</v-icon>
<h1 class="title oswald my_dark_purple_text pl-2 pr-5">ENTER YOUR AMAZON CREDENTIALS BELOW</h1>
</v-card-title>
<v-form ref="form" v-model="valid">
<h1>creds</h1>









share|improve this question





















  • maybe its because your using v-for directive on the root tag. (<template>). its forbidden in vuejs. try wrapping your content in one root element. it should help.
    – Efrat
    Nov 10 at 22:16










  • Great thanks.. heck I'll try anything
    – ToddT
    Nov 10 at 23:00










  • @Elfrat, root tag(template) can be used with v-for for iteration (vuejs.org/v2/guide/list.html#v-for-on-a-lt-template-gt). Toddt, I created a codepen and it appears to work well. Something else may be blocking or causing the issue
    – nara_l
    Nov 11 at 2:31












up vote
0
down vote

favorite









up vote
0
down vote

favorite











I'm passing an array from a parent component to a child. The array is being passed and I can access the entire array, but for some reason when I try and access on array element I can't.



(This is shortened for brevity's sake)



When I do this:



<template v-for="creds in amazonCredsArray">
<v-container fluid grid-list-lg class="come_closer">
<v-layout row wrap>
<v-flex xs12>
<v-card class="lightpurple">
<v-card-title>
<v-icon class="my_dark_purple_text">language</v-icon>
<h1 class="title oswald my_dark_purple_text pl-2 pr-5">ENTER YOUR AMAZON CREDENTIALS BELOW</h1>
</v-card-title>
<v-form ref="form" v-model="valid">
<h1>amazonCredsArray</h1>


I can see the amazonCredsArray displayed.. it looks like this:



[ "auth_token": "amzn.mws.9cb254dXXXXX", "seller_id": "CXDFDFDF", "marketplace": "asdfasdfasdf", "zones": [ "name": "United States", "id": 1 ] , "auth_token": "asjdfljakldfjlsadf", "seller_id": "ddeeee", "marketplace": "12", "zones": [ "name": "United States", "id": 1 ] ]


However when I try to use creds in that same place in the view, I don't get anything. I'm trying this:



<template v-for="creds in amazonCredsArray">
<v-container fluid grid-list-lg class="come_closer">
<v-layout row wrap>
<v-flex xs12>
<v-card class="lightpurple">
<v-card-title>
<v-icon class="my_dark_purple_text">language</v-icon>
<h1 class="title oswald my_dark_purple_text pl-2 pr-5">ENTER YOUR AMAZON CREDENTIALS BELOW</h1>
</v-card-title>
<v-form ref="form" v-model="valid">
<h1>creds</h1>









share|improve this question













I'm passing an array from a parent component to a child. The array is being passed and I can access the entire array, but for some reason when I try and access on array element I can't.



(This is shortened for brevity's sake)



When I do this:



<template v-for="creds in amazonCredsArray">
<v-container fluid grid-list-lg class="come_closer">
<v-layout row wrap>
<v-flex xs12>
<v-card class="lightpurple">
<v-card-title>
<v-icon class="my_dark_purple_text">language</v-icon>
<h1 class="title oswald my_dark_purple_text pl-2 pr-5">ENTER YOUR AMAZON CREDENTIALS BELOW</h1>
</v-card-title>
<v-form ref="form" v-model="valid">
<h1>amazonCredsArray</h1>


I can see the amazonCredsArray displayed.. it looks like this:



[ "auth_token": "amzn.mws.9cb254dXXXXX", "seller_id": "CXDFDFDF", "marketplace": "asdfasdfasdf", "zones": [ "name": "United States", "id": 1 ] , "auth_token": "asjdfljakldfjlsadf", "seller_id": "ddeeee", "marketplace": "12", "zones": [ "name": "United States", "id": 1 ] ]


However when I try to use creds in that same place in the view, I don't get anything. I'm trying this:



<template v-for="creds in amazonCredsArray">
<v-container fluid grid-list-lg class="come_closer">
<v-layout row wrap>
<v-flex xs12>
<v-card class="lightpurple">
<v-card-title>
<v-icon class="my_dark_purple_text">language</v-icon>
<h1 class="title oswald my_dark_purple_text pl-2 pr-5">ENTER YOUR AMAZON CREDENTIALS BELOW</h1>
</v-card-title>
<v-form ref="form" v-model="valid">
<h1>creds</h1>






vue.js vuejs2 vue-component






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 10 at 21:53









ToddT

6801622




6801622











  • maybe its because your using v-for directive on the root tag. (<template>). its forbidden in vuejs. try wrapping your content in one root element. it should help.
    – Efrat
    Nov 10 at 22:16










  • Great thanks.. heck I'll try anything
    – ToddT
    Nov 10 at 23:00










  • @Elfrat, root tag(template) can be used with v-for for iteration (vuejs.org/v2/guide/list.html#v-for-on-a-lt-template-gt). Toddt, I created a codepen and it appears to work well. Something else may be blocking or causing the issue
    – nara_l
    Nov 11 at 2:31
















  • maybe its because your using v-for directive on the root tag. (<template>). its forbidden in vuejs. try wrapping your content in one root element. it should help.
    – Efrat
    Nov 10 at 22:16










  • Great thanks.. heck I'll try anything
    – ToddT
    Nov 10 at 23:00










  • @Elfrat, root tag(template) can be used with v-for for iteration (vuejs.org/v2/guide/list.html#v-for-on-a-lt-template-gt). Toddt, I created a codepen and it appears to work well. Something else may be blocking or causing the issue
    – nara_l
    Nov 11 at 2:31















maybe its because your using v-for directive on the root tag. (<template>). its forbidden in vuejs. try wrapping your content in one root element. it should help.
– Efrat
Nov 10 at 22:16




maybe its because your using v-for directive on the root tag. (<template>). its forbidden in vuejs. try wrapping your content in one root element. it should help.
– Efrat
Nov 10 at 22:16












Great thanks.. heck I'll try anything
– ToddT
Nov 10 at 23:00




Great thanks.. heck I'll try anything
– ToddT
Nov 10 at 23:00












@Elfrat, root tag(template) can be used with v-for for iteration (vuejs.org/v2/guide/list.html#v-for-on-a-lt-template-gt). Toddt, I created a codepen and it appears to work well. Something else may be blocking or causing the issue
– nara_l
Nov 11 at 2:31




@Elfrat, root tag(template) can be used with v-for for iteration (vuejs.org/v2/guide/list.html#v-for-on-a-lt-template-gt). Toddt, I created a codepen and it appears to work well. Something else may be blocking or causing the issue
– nara_l
Nov 11 at 2:31












1 Answer
1






active

oldest

votes

















up vote
0
down vote













Try this out:



<template v-for="(creds, index) in amazonCredsArray" :key="creds.seller_id"> 





share|improve this answer




















    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',
    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%2f53243779%2fvuejs-cannot-access-array-element-using-v-for-in-child-component%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








    up vote
    0
    down vote













    Try this out:



    <template v-for="(creds, index) in amazonCredsArray" :key="creds.seller_id"> 





    share|improve this answer
























      up vote
      0
      down vote













      Try this out:



      <template v-for="(creds, index) in amazonCredsArray" :key="creds.seller_id"> 





      share|improve this answer






















        up vote
        0
        down vote










        up vote
        0
        down vote









        Try this out:



        <template v-for="(creds, index) in amazonCredsArray" :key="creds.seller_id"> 





        share|improve this answer












        Try this out:



        <template v-for="(creds, index) in amazonCredsArray" :key="creds.seller_id"> 






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 11 at 13:05









        Daniyal Lukmanov

        1810




        1810



























             

            draft saved


            draft discarded















































             


            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53243779%2fvuejs-cannot-access-array-element-using-v-for-in-child-component%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







            這個網誌中的熱門文章

            How to read a connectionString WITH PROVIDER in .NET Core?

            In R, how to develop a multiplot heatmap.2 figure showing key labels successfully

            Museum of Modern and Contemporary Art of Trento and Rovereto