question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

<template> tag with v-for render undefined

See original GitHub issue

if i use a Array as a prop of custom component, the template element with v-for directive just render undefined

<component :list="list"></component>
<template v-for="item of list">{{item.name}}</template> <!-- output undefined -->

it’s strange. only template element tag has this problem.

Vue.js version

2.1.7

Reproduction Link

simple demo here https://github.com/shjyh/vue_error_demo/tree/master/2016-12-26

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:13 (5 by maintainers)

github_iconTop GitHub Comments

4reactions
dankuckcommented, Jan 6, 2017

I’m still seeing a similar problem when running against the latest code.

Example: https://dankuck.github.io/TiltMaker/buggy.html

References: https://cdn.rawgit.com/vuejs/vue/dev/dist/vue.js

Github: https://github.com/dankuck/TiltMaker

4reactions
posvacommented, Dec 26, 2016

The template tag is meant to wrap multiple elements like:

<template v-for="item in list">
   <span>{{ item.key }}</span>
  <span> {{ item.name }}</span>
</template>

In your case you should simply use <span v-for="item in list"></span> to wrap the text nodes

Read more comments on GitHub >

github_iconTop Results From Across the Web

VueJS - v-for getting undefined value from props nested object
My component's template and the props are below <template> <div> <label>WorkHours</label> <div v-for="(data, day) in value.config.
Read more >
v-for loop rendering keeps throwing 'undefined' error - Laracasts
This is the error: TypeError: Cannot read property 'account' of undefined This is a segment of my html template, the v-for logic:
Read more >
Template Syntax | Vue.js
Vue uses an HTML-based template syntax that allows you to declaratively ... or undefined , then the attribute will be removed from the...
Read more >
More Ways to a Templates to Vue Components
Render functions return elements that are rendered by Vue. ... All we had to do is include a template tag to render the...
Read more >
Adding a new todo form: Vue events, methods, and models
Add a blank <template> and a <script> tag like before: ... Our todo list app rendered with a text input to enter new...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found