Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/434.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何在嵌套循环中使用v-for?_Javascript_Vuejs2_Wordpress Rest Api - Fatal编程技术网

Javascript 如何在嵌套循环中使用v-for?

Javascript 如何在嵌套循环中使用v-for?,javascript,vuejs2,wordpress-rest-api,Javascript,Vuejs2,Wordpress Rest Api,我试图使用VueJs2框架过滤JSON对象(在我的示例中,该对象名为“post”),该框架使用Wordpress REST API中的数据对象。当用户在我的输入元素中键入搜索查询时,我有与我的帖子相关联的嵌套数组(元数据标记): HTML: 如果你能就如何进行提供一些建议,那就太好了。谢谢。我更新了您的。您需要循环遍历数组的项,而不是整个搜索的数组 <div id="app" class="container" style="padding-top: 2em;">

我试图使用VueJs2框架过滤JSON对象(在我的示例中,该对象名为“post”),该框架使用Wordpress REST API中的数据对象。当用户在我的输入元素中键入搜索查询时,我有与我的帖子相关联的嵌套数组(元数据标记):

HTML:

如果你能就如何进行提供一些建议,那就太好了。谢谢。

我更新了您的。您需要循环遍历数组的项,而不是整个搜索的数组

<div id="app" class="container" style="padding-top: 2em;">      
  <input v-model="searchText">

  <table class="table table-striped" v-if="posts">
    <thead>
      <tr>
        <th>Title</th>
        <th>Product Type</th>
        <th>Tags</th>
      </tr>
    </thead>
    <tr v-for="post in itemsSearched">
      <td>
        <a :href="post.link" target="_blank">
          <img :src="post._embedded['wp:featuredmedia'][0].media_details.sizes.thumbnail.source_url"
             style="width:75px;height:75px;"/>
        </a>
      </td>
      <td>
        <a :href="post.link" target="_blank" v-html="post.title.rendered"></a><br/>
        <div v-html="post.content.rendered"></div>
      </td>
      <td v-for="item in post._embedded['wp:term']">
        <div v-for="subItem in item">
          <a :href="subItem.link">{{subItem.name}}</a>
        </div>
      </td>
    </tr>
  </table>
</div>

标题
产品类型
标签

我更新了您的。您需要循环遍历数组的项,而不是整个搜索的数组

<div id="app" class="container" style="padding-top: 2em;">      
  <input v-model="searchText">

  <table class="table table-striped" v-if="posts">
    <thead>
      <tr>
        <th>Title</th>
        <th>Product Type</th>
        <th>Tags</th>
      </tr>
    </thead>
    <tr v-for="post in itemsSearched">
      <td>
        <a :href="post.link" target="_blank">
          <img :src="post._embedded['wp:featuredmedia'][0].media_details.sizes.thumbnail.source_url"
             style="width:75px;height:75px;"/>
        </a>
      </td>
      <td>
        <a :href="post.link" target="_blank" v-html="post.title.rendered"></a><br/>
        <div v-html="post.content.rendered"></div>
      </td>
      <td v-for="item in post._embedded['wp:term']">
        <div v-for="subItem in item">
          <a :href="subItem.link">{{subItem.name}}</a>
        </div>
      </td>
    </tr>
  </table>
</div>

标题
产品类型
标签


我正在创造一个类似这样的东西

母公司

-姓名:

--儿童对象1

--迈森

---儿童对象2

---我的孙辈


我正在创造一个类似这样的东西

母公司

-姓名:

--儿童对象1

--迈森

---儿童对象2


---My孙子

要搜索对象的哪些关键点?你能更好地了解一下你想要的布局吗?您希望每个匹配的属性都有一个TD?您希望搜索对象的哪些键?你能更好地了解一下你想要的布局吗?您希望每个匹配的属性都有一个TD?
<div id="app" class="container" style="padding-top: 2em;">      
  <input v-model="searchText">

  <table class="table table-striped" v-if="posts">
    <thead>
      <tr>
        <th>Title</th>
        <th>Product Type</th>
        <th>Tags</th>
      </tr>
    </thead>
    <tr v-for="post in itemsSearched">
      <td>
        <a :href="post.link" target="_blank">
          <img :src="post._embedded['wp:featuredmedia'][0].media_details.sizes.thumbnail.source_url"
             style="width:75px;height:75px;"/>
        </a>
      </td>
      <td>
        <a :href="post.link" target="_blank" v-html="post.title.rendered"></a><br/>
        <div v-html="post.content.rendered"></div>
      </td>
      <td v-for="item in post._embedded['wp:term']">
        <div v-for="subItem in item">
          <a :href="subItem.link">{{subItem.name}}</a>
        </div>
      </td>
    </tr>
  </table>
</div>
<div v-for="item in parentObject">
<div v-for="item2 in item.childObject1">
<div v-for="item3 in item2.chileObject2"></div>
</div>
</div>