简体   繁体   English

如何正确警告 reactjs 中的某些变量姓氏和名字

[英]How to properly alert certain variable lastname and firstname in reactjs

I am working with airtable.com database.我正在使用 airtable.com 数据库。 Here I am trying to display of a record of a particular table where table id is 101.在这里,我试图显示表 id 为 101 的特定表的记录。

Everything works fine as records are displayed.显示记录时一切正常。

Here is my issue: I need to alert lastname and firstname of that record so I have added:这是我的问题:我需要提醒该记录的姓氏名字,所以我添加了:

alert(record.lastname);
alert(record.firstname);

but nothing is alerted.但没有任何警报。

Here is the code that successfully displayed records:下面是成功显示记录的代码:

 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 returns an array so alert line should be like this. filter function 返回一个数组,所以警报行应该是这样的。 alert(recordSearch[0].lastname)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用reactjs通过json数据在列表中显示用户的名字和姓氏的第一个字母而不是图像 - 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 can i change firstname/lastname to firstName/lastName in react? the problem is that it comes from the backend 如何显示元素名字和姓氏...来自 strore redux - how to display element firstname and lastname ... from strore redux 如何在 mui 数据表的同一列中显示名字和姓氏? - how do i display firstname and lastname in same column in mui data tables? 当我记录 mixCategory 是 firstName[object Object]lastName,如何在字符串中插入图标 - When I log mixedCategory is firstName[object Object]lastName, How to insert icon inside a string 如何使用异步值(Reactjs)正确加载全局变量? - How to properly load global variable with async values(Reactjs)? 其余管理员创建表单-将firstName和lastName合并到第三个字段中 - Admin on rest Create form - merge firstName and lastName into a third field 我可以部分显示我的内容(显示名字而不是名字和姓氏) - I can partially display my content (displaying firstName instead of firstName and lastName) reactjs中的警报 - Alert in reactjs 如何检查 reactjs 中警报中的 eles 条件 - how to check if eles condition in alert in reactjs
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM