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.

use $index in component

See original GitHub issue

Hi , i have a component <image-upload></image-upload> but i used it in v-for so i need to send the current index to component to use it when dispatch event , so how could i use something like <image-upload index="{{ $index }}"></image-upload> ?

Issue Analytics

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

github_iconTop GitHub Comments

13reactions
fnlctrlcommented, Sep 13, 2016

First, define a prop called index inside <image-upload> that accepts a Number (you can give it another name if you’d like), Then, pass the index using <image-upload :index="index"></image-upload>

Please read more about components and passing props here: http://vuejs.org/guide/components.html#Passing-Data-with-Props

3reactions
fnlctrlcommented, Sep 13, 2016

Hi, thanks for filling this issue, however the issue tracker is reserved for bug reports and feature requests only, so please use our dedicated gitter or forum to ask questions.


There is a section in the guide explaining this: http://vuejs.org/guide/list.html

<div v-for="(index, item) in items">
  {{ index }} {{ item.message }}
</div>

Please avoid using $index as it’s deprecated in 2.0

Read more comments on GitHub >

github_iconTop Results From Across the Web

How do index.js files work in React component directories?
An index.js file allow you to import (or require() ) its parent folder as a module. This behavior is copied from Node.
Read more >
How to use index.js file(Properly) - DEV Community ‍ ‍
this can be solved by using the index. js file only to export. import React from 'react'; const SomeComponent = () => {...
Read more >
This or that? Component Names: index.js or ... - Brad Frost
The idea of this approach is to have Component.js contain the guts of the component, while index.js merely imports that component file and ......
Read more >
Managing Z-Index In A Component-Based Web Application
Within a component's CSS file, maintain z-index values any way you like. It might be consecutive values, or you could give them a...
Read more >
Importing React Components using Index.js - Default Export
Hey'll; This is Happy; Welcome back to the New Coding Recipe; By using the index.js we will import the components as an object...
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