Giter Club home page Giter Club logo

Comments (10)

yyx990803 avatar yyx990803 commented on May 8, 2024

Here's a version that works. It seems using identifier with objects causes problems...

Also, when you are iterating over an object of objects, those objects are used directly as the child vm's root $data. In comparison, $value is only available for primitive values.

Basically, v-repeat doesn't play too well when doing nested loops of objects. If you have control over your data structure it might be better to use Arrays where appropriate.

from discussion.

Neru avatar Neru commented on May 8, 2024

Thanks. This solves the issue. It might worth adding the example to the "Displaying a List" guide on the Vue.js website.

from discussion.

peterfoeng avatar peterfoeng commented on May 8, 2024

this is golden! Thanks

from discussion.

tiffon avatar tiffon commented on May 8, 2024

An updated sample: http://jsfiddle.net/8WqxC/2/

On this data:

var playlists =  {
    "Favourite Songs": {
        "2014": ['song a', 'song b'],
        "2013": ['song c', 'song d', 'song e']
    },
    "Favourite Genres": {
        "Pop": ['song a'],
        "Rock": ['song b'],
        "Hip Hop": ['song c', 'song d', 'song e']
    }
}

With this markup:

<ul id="menu">
    <li v-repeat="playlist : playlists">
        {{$key}}
        <ul>
            <li v-repeat="sublist : playlist">
                {{$key}}
                <ul>
                    <li v-repeat="sublist">
                        {{$value}}
                    </li>
                </ul>
            </li>
        </ul>
    </li>
</ul>

from discussion.

fer-ri avatar fer-ri commented on May 8, 2024

@tiffon Thanks a lot 👍

from discussion.

mattiasottosson avatar mattiasottosson commented on May 8, 2024

Just started using vue-js, and I wonder if this method is deprecated in favor of v-for?
Is this how you should do it in 1.0?

http://jsfiddle.net/z7mrmx1a/

from discussion.

simplesmiler avatar simplesmiler commented on May 8, 2024

@mattiasottosson yes, v-repeat is deprecated in favor of v-for. There's also syntax for manually specifying key: v-for="(key, value) in object" and v-for="(index, value) in list".

We also don't use vuejs/Discussion anymore. You can find help on the forum or gitter chat.

from discussion.

DoDSoftware avatar DoDSoftware commented on May 8, 2024

@simplesmiler isn't it actually v-for="(value, key) in object and v-for="(value, index) in list" ? That is to say, isn't the value the first parameter? (counterintuitive though it is)

https://vuejs.org/v2/api/#v-for

from discussion.

simplesmiler avatar simplesmiler commented on May 8, 2024

@DelightedD0D please note the date, this was before 2.0.

from discussion.

DoDSoftware avatar DoDSoftware commented on May 8, 2024

@simplesmiler fair enough :)

from discussion.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.