1

In Vue.js I'm trying to pass values from a loop as properties for a custom component.

<template v-for="upload in uploads">
   <upload-container index="{{ $index }}" filename="{{ upload.name }}"></upload-container>
 </template>

Unfortunately this does not work and it only passes through the literal strings {{ $index }} and {{ upload.name }} instead of the actual values.

1 Answer 1

2

The values are in fact, passed down as strings. If you want to evaluate the expressions you need to use dynamic syntax.

<template v-for="upload in uploads">
   <upload-container :index="$index" :filename="upload.name"></upload-container>
 </template>

Literal vs Dynamic

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.