我只想显示以下 json 中的一些数据:https ://randomuser.me/api/?results=10
在 Boostrap-Vue 表中,我应该导出数据,但它没有显示。
我的代码如下,我只想显示某些数据,例如名字和姓氏。
<template lang="html">
<div>
<b-table striped hover :personas="personas" :fields="fields"></b-table>
</div>
</template>
<script>
export default {
name: 'Agenda',
data () {
return {
fields: {
last_name: {
label: 'Person last name',
sortable: true
},
first_name: {
label: 'Person first name',
sortable: true
}
},
personas: []
}
},
created: function () {
this.obtenerAPI()
},
methods: {
obtenerAPI () {
this.$http.get('https://randomuser.me/api/?results=10')
.then(function (respuesta) {
this.personas = respuesta.body.results
console.log(this.personas)
})
}
}
}
</script>
<style lang="css">
</style>
我怎样才能向他们展示?
问题在于
first_name
,由. 相反,我们可以找到和。last_name
JSON
randomuser
name.first
name.last
为了访问嵌套值,我们可以利用
Scoped field slots
我们声明slot
等于名称的位置,field.key
并在其中添加表达式data.item.*
以打印所需的值。解决方案:
你可以这样做:
示范: