WIX API 获取中继器
WIX API fetch to repeater
我在填充 wix API 将数据提取到转发器时遇到问题,尽管我确实遵循了此处的一些示例,但我遇到了错误,不确定为什么...
Link 举个例子:
这里是错误:
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;
}
每个项目必须有唯一的 ID。
在此处安装uuid
https://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;
});
// .....
我在填充 wix API 将数据提取到转发器时遇到问题,尽管我确实遵循了此处的一些示例,但我遇到了错误,不确定为什么...
Link 举个例子:
这里是错误:
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;
}
每个项目必须有唯一的 ID。
在此处安装uuid
https://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;
});
// .....