將vue.js與vue-router一起使用,並與WP Rest API 2一起使用,從而不會加載足夠快的數據。 當我切換到路由時, div出現應該保存內容,然後內容最終加載。我也收到此錯誤:Rest API使用vue.js和vue-router
[Vue公司提醒]:錯誤評估表達「content.content.rendered」時:類型錯誤:無法讀取的不確定
內容將在計算機上加載最終「渲染」屬性,即使出現錯誤,但在移動設備上,內容根本不會顯示。這是我的方法確實抓住特定頁面。我曾嘗試使用nextTick,但無法使其正常工作。
任何幫助將不勝感激,請讓我知道,如果你需要更多的信息。
<template>
<div>
<div class="animated cateringWrap">
<h1>{{ content.title.rendered }}</h1>
{{{ content.content.rendered }}}
</div>
</div>
</template>
<script>
export default {
data() {
return {
content: []
}
},
ready: function(){
this.loadContent();
},
methods: {
loadContent: function() {
this.$http.get('http://localhost/t/wp-json/wp/v2/pages/82').then(function(response){
this.content = response.data;
});
}
}
}
</script>
alt text http://oi67.tinypic.com/20ker05.jpg
我建議在這裏發佈代碼,而不是圖像。 – crabbly