After receiving the data, the path to the required looks like this:
{{list._links.wp:featuremedia[0].href}} But, Vue.js does not understand " : ".
How can this be fixed?
In addition to the comments above ... Try this:
const app = new Vue({ el: '#app', data() { return { lists: [{ title: 'title 1' }, { title: 'title 2' }] } }, methods: { getHref(list) { return (list && list.hasOwnProperty('wp:featuremedia')) ? list['wp:featuremedia'][0].href : 'Loading...'; } }, created() { setTimeout(() => { this.lists = this.lists.map((el) => { return { ...el, 'wp:featuremedia': [{ href: 'link 1' }, { href: 'link 2' }, { href: 'link 3' }] } }); }, 2000) } }) <script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.17/vue.js"></script> <div id="app"> <ul> <li v-for="list in lists"> <h3>{{list.title}}</h3> <p>First link: {{ getHref(list) }}</p> </li> </ul> </div> It uses boot simulation via setTimeout . By default, lists have no wp:featuremedia , we load it, and then, using the getHref method (which receives one of the lists elements as input), we get the value of the link (if the list && list.hasOwnProperty('wp:featuremedia') complied with). Otherwise, write " Loading ... ".
Source: https://ru.stackoverflow.com/questions/943957/
All Articles
{{list.title.rendered}}works. Here is such a div<div v-for="list in lists" v-bind:key="list.id">ErrorUnexpected token :- Slava Pavlovlist._links.wpsuppose it contains some data, why are you doing this here:featuremedia[0].href? If you just want to displayЗНАЧЕНИЕ : ЗНАЧЕНИЕ, this is done like this:{{list._links.wp}}:{{featuremedia[0].href}}or like this:{{`${list._links.wp}:${featuremedia[0].href}`}}- Kvilios{{ list._links["wp:featuremedia"][0].href }}- Kvilios 2:41 pm