我正在尝试从api中提取json的FlatList,但是我一直收到这个错误:
Warning: Each child in an array or iterator should have a unique "key" prop.
Check the render method of `VirtualizedList`.
Run Code Online (Sandbox Code Playgroud)
相关代码:
<FlatList
data={this.props.tunes}
keyExtractor={(item, index) => item.id}
renderItem={({item}) => {
<Item
key={item.id}
title={item.title}
composer={item.composer}
year={item.year}
/>
}}
/>
Run Code Online (Sandbox Code Playgroud)
我确定有一个简单的解决办法,但经过几天尝试不同的事情,我还没有找到它.谢谢你的帮助!
我有一个文本视图列表,其中包括保存为 int 的年份。我在一个内插字符串中显示它:
Text("\($0.property) \($0.year) \($0.etc)")
Run Code Online (Sandbox Code Playgroud)
问题是,它在 int 中添加了一个逗号,例如它显示 1,944 而不是 1944 年。我确定这是一个简单的修复,但我一直无法弄清楚如何删除逗号。谢谢!
我有一个父母div,包含两个孩子,并排.第一个孩子是一个图像,必须是高度100%和58%宽度,边距自动和溢出隐藏.第二个子项包含文本,文本的长度决定了父项的高度.这是几个页面的模板,具有不同的文本长度,因此父级高度不同.如果不使用JS,我可以做我想做的事吗?感谢您的输入!代码如下.
HTML:
<div id="product-summary">
<div class="product-image-container">
<img />
</div>
<div id="product-details">
<h3 class="product-title"></h3>
<div class="product-description"></div>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
CSS:
.product-image-container {
position: absolute;
top: 0;
left: 0;
width: 58%;
height: 100%;
overflow: hidden;
img {
position: absolute;
top: 0;
left: 50%;
margin: auto;
transform: translateX(-50%);
min-width: 100%;
height: 100%;
}
}
#product-details {
float: right;
border: solid thin #777;
height: ~"calc(100% - 2px)";
width: 41%;
text-align: center;
}
Run Code Online (Sandbox Code Playgroud)