![](/img/trans.png)
[英]How to show first letters of the firstname and lastname of the user in the list instead of image through json data using reactjs
[英]How to properly alert certain variable lastname and firstname in reactjs
我正在使用 airtable.com 数据库。 在这里,我试图显示表 id 为 101 的特定表的记录。
显示记录时一切正常。
这是我的问题:我需要提醒该记录的姓氏和名字,所以我添加了:
alert(record.lastname);
alert(record.firstname);
但没有任何警报。
下面是成功显示记录的代码:
function RecordList1() {
const base = useBase();
const table = base.getTableByNameIfExists('my-tablename-here');
// grab all the records from that table
const records = useRecords(table);
const recordSearch = records.filter(record => record.id == '101');
//alert(record.lastname);
//alert(record.firstname);
// render a list of records:
return (
<ul>
{recordSearch.map(record => {
return <li key={record.id}>{record.id} -- {record.lastname} ---- {record.firstname}</li>
})}
</ul>
);
}
filter
function 返回一个数组,所以警报行应该是这样的。 alert(recordSearch[0].lastname)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.