我的問題是使用這個json。 http://dev-rexolution.pantheonsite.io/api/noticiasVue.js使用json
我需要消耗vuejs 2只有數組的第一個元素才能夠顯示它,與我工作的控制檯一起工作但沒有vuejs。
此控制檯日誌工作:console.log(response.data [0] .title [0] .value);
<template>
<div class="Box Box--destacado1">
<div class="Media Media--rev">
<div class="Media-image">
</div>
<div class="Media-body">
<span class="Box-info">{{ noticias[0].field_fecha[0].value}}</span>
<h3 class="Box-title">
<a href="">{{ /*noticias[0].title[0].value */}}</a>
</h3>
<p class="Box-text">{{/*noticias[0].field_resumen[0].value*/}}</p>
</div>
</div>
</template>
<script>
import axios from 'axios';
export default {
data:() => ({
noticias: [],
errors: []
}),
// Fetches posts when the component is created.
created() {
axios.get(`http://dev-rexolution.pantheonsite.io/api/noticias`)
.then(response => {
// JSON responses are automatically parsed.
this.noticias = response.data
})
.catch(e => {
this.errors.push(e)
})
}
}
</script>
你究竟是什麼意思的*「不工作」*?另外,爲什麼要爲您的網址使用字符串模板文字? – Phil
快速瀏覽您的瀏覽器*控制檯*和*網絡*開發工具應該會顯示您可能遇到的任何問題 – Phil
此模板由Drupal 8模塊Rest生成。不工作,因爲它將對象返回爲undefined –