有一个子组件如下:
import React from 'react'
export type ItemType = {
type: "property" | "method",
value: string,
selected?: boolean
}
export type SubContainerProps = {
height?: number,
title: string,
data: ItemType[], // 这个是items
}
export default function subContainer (props: SubContainerProps){
return (
<div style={{borderRadius: '8px', border: '2px dashed #333', height: props.height}}>
<div style={{textAlign: 'left'}}>
<label>{props.title}</label>
</div>
<div>
{props.data.map((item, index) => (
<div
key={`${index}-${item.type}-${item.value} `}
style={{
float: 'left',
display: 'inline-block',
borderRadius: '6px',
border: '2px solid #000',
margin: '8px',
padding:'4px',
backgroundColor: item.selected ? '#39fe40': ''
}}
>{item.value}</div>
))}
</div>
</div>
)
}
但是传输的props.data 内容比较多的时候,会超出界面如图:
想要是超出界面就进行滑条展示,可以上下拖动滑条展示,请问如何做呢?
加多一行,溢出滚动
overflow: 'auto'