javascript - Include JavaScript inside Material-UI tags
问题描述
I have this material-ui ListItemText
:
<ListItemText primary={<div>
<Table className={classes.table}>
<TableRow>
<TableCell width="40">{item.issue_state}</TableCell>
<TableCell width="40">{item.issue_number}</TableCell>
<TableCell width="600">{item.issue_title}</TableCell>
<TableCell width="600">{item.issue_url}</TableCell>
</TableRow>
</Table>
</div>}/>
Rather than displaying the URL, I'd like to have something like this:
if (item.issue_url.includes("github.com") {
item.issue_url = 'Public'
}
else if (item.issue_url.includes("github.company.com") {
item.issue_url = 'Private'
}
where the TableCell
displays Public
of Private
rather than the whole URL. Can this be done?
解决方案
you could use as below,
<ListItemText primary={<div>
<Table className={classes.table}>
<TableRow>
<TableCell width="40">{item.issue_state}</TableCell>
<TableCell width="40">{item.issue_number}</TableCell>
<TableCell width="600">{item.issue_title}</TableCell>
<TableCell width="600">{
(item.issue_url.indexOf('github.company.com') >=0)
? 'Private'
: ((item.issue._url.indexOf('github.com') >=0)
? 'Public'
: '')
}</TableCell>
</TableRow>
</Table>
</div>}/>
Otherwise, good idea is to create a derived property in item based on issue_url
推荐阅读
- vue.js - 在 Apollo 提供程序中更改 Apollo 端点
- three.js - THREE.js:如何为平移、旋转和缩放制作 4X4 矩阵
- mocking - 开玩笑快照失败:val.getMockName 不是函数
- ms-access - 访问 2016 自动增加数字然后重置为 1
- css - 在引导表中显示内联内容
- java - 并发修改异常迭代
- python - 有没有更有效的方法来找到大量矩阵的平均值?
- gradle - 如何确定给定依赖项的可用级别?
- installation - 安装 Anaconda 和 Miniconda
- anaconda - Windows 上的 Conda Pytorch 导致 HTTP 连接错误