【问题标题】:WIX API fetch to repeaterWIX API 提取到中继器
【发布时间】:2019-11-25 12:43:49
【问题描述】:

我在将 wix API 获取的数据填充到中继器时遇到问题,尽管我确实按照一些示例在这里我得到了一个错误,不知道为什么......

示例链接:Wix: Populate repeater with external API call

这是错误:

Wix code SDK error: Each item in the items array must have a member named `_id` which contains a unique value identifying the item.
Wix code SDK Warning: The data that was passed to data contained at least two items with the same ID: . Only the first item was accepted.

我当前的代码

import {getCurrentTemp} from 'backend/serviceModule';

//...

    export function buttonFetch_click(event, $w) {
      getCurrentTemp($w("#emailInput").value)
        .then(CurrentTemp => {
          // add an _id property to each  object
          CurrentTemp.forEach(item => item._id = item.id)
          // feed the data to the repeater
          $w('#repeater1').data = CurrentTemp;
        } );
    }

    export function repeater1_itemReady($item, itemData, index) {
      $item("#textResults").text = "Name: " + itemData.Title + "\n"
        + "Symbol: " + itemData.BreachDate + "\n"
        + "Rank: " + itemData.Description + "\n"
        + "Price (USD): " + itemData.DataClasses;
    }

【问题讨论】:

  • 请帮忙解决这个问题……一天前发布的……还没有帮助!!

标签: api repeater velo


【解决方案1】:

每个项目都必须有唯一的 id。

在此处安装uuidhttps://support.wix.com/en/article/corvid-managing-external-code-libraries-with-the-package-manager

并为每个项目设置 ID

import uuid from 'uuid';

// .....

$w('#repeater1').data = CurrentTemp.map((item) => {
  item._id = uuid();
  return item;
});

// .....

【讨论】:

  • 谢谢我还是解决了这个问题...不同的方法...谢谢
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多