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>
vue.js vuejs2 vue-component
add a comment |
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>
vue.js vuejs2 vue-component
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
add a comment |
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>
vue.js vuejs2 vue-component
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
vue.js vuejs2 vue-component
asked Nov 10 at 21:53
ToddT
7001722
7001722
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
add a comment |
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
add a comment |
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">
add a comment |
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
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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">
add a comment |
up vote
0
down vote
Try this out:
<template v-for="(creds, index) in amazonCredsArray" :key="creds.seller_id">
add a comment |
up vote
0
down vote
up vote
0
down vote
Try this out:
<template v-for="(creds, index) in amazonCredsArray" :key="creds.seller_id">
Try this out:
<template v-for="(creds, index) in amazonCredsArray" :key="creds.seller_id">
answered Nov 11 at 13:05
Daniyal Lukmanov
1810
1810
add a comment |
add a comment |
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.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- 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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
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