【问题标题】:Get the content by page id/slug with the Wordpress Rest API使用 Wordpress Rest API 按页面 id/slug 获取内容
【发布时间】:2019-12-16 01:23:21
【问题描述】:

使用 Wordpress Rest API 作为我的后端,使用 Nuxt.js 作为我的前端,但尝试通过 ID/Slug 从页面中获取数据,因为页面将被 Gutenberg 块填充......现在我遇到了问题我只得到了第一个 ID 并用

完成了地图结构
  1. 翁德维斯/
  2. index.vue
  3. _slug.vue
export default {
  async asyncData ({ app, store, params }) {
    let page = await app.$axios.get(`${store.state.wordpressAPI}/wp/v2/pages?parent=77&_embed`)
    store.commit('setPage', page.data[0])
  },

  computed: {
    page () {
        return this.$store.state.page
    }
  }
}

【问题讨论】:

    标签: javascript wordpress vue.js nuxt.js wordpress-rest-api


    【解决方案1】:

    你能展示你的 HTML 部分,你在哪里渲染你的东西吗? 比如:

    <div :id="page.title.rendered" exact class="page__content" v-html="page.content.rendered"></div>
    

    【讨论】:

      猜你喜欢
      • 2020-04-20
      • 1970-01-01
      • 2016-06-17
      • 2021-05-21
      • 1970-01-01
      • 1970-01-01
      • 2019-01-10
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多