B
B
BonBon Slick2017-10-19 13:54:37
Vue.js
BonBon Slick, 2017-10-19 13:54:37

Why does v-for on an object output each character instead of the value?

console.log(this.apps);
[{"header_image":"http:\/\/cdn.akamai.steamstatic.com\/steam\/apps\/372512\/header.jpg?t=1447374903"},{"header_image":"http:\/\/cdn.akamai.steamstatic.com\/steam\/apps\/412242\/header.jpg?t=1498162058"}]

 mounted: function () {
            for(let i = 0; i < this.apps.length; ++i){
                console.log(this.apps[i].header_image);
            }

        },

// return 
405 undefined

Outputs 203 characters.

If render in html
<div class="col-md-1 last_wins-app  roll-item-wrap" v-for="(value, propertyName) in apps">
                     {{ value }}
                </div>

Each letter will be displayed separately...

Why so?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
0
0xD34F, 2017-10-19
@BonBonSlick

Probably json forgot to parse. Lines v-forand processes - character by character.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question