下拉选择框出来的时候要异步设置一下,可能会还没塞入节点就发送ifreme通信,重点是iframeRef的通信
<Select
ref={selectRef}
style={{ flex: 1 }}
listHeight={120}
onChange={handleChange}
options={selectOption}
value={selectVal['iotId'] || null}
fieldNames={{
label: 'name',
value: 'iotId'
}}
popupClassName='selectDropBlock'
notFoundContent={
<div style={{ color: '#12C2FC' }}>没有匹配的数据</div>
}
onDropdownVisibleChange={(open) => {
if (open) {
setTimeout(() => {
const selectDropdown =
document.getElementsByClassName('selectDropBlock')
if (selectDropdown && selectDropdown.length != 0) {
iframeRef.current.contentWindow.postMessage({
action: 'coverVideo',
data: 'selectDropBlock' // 选填,默认
})
}
}, 250)
} else {
iframeRef.current.contentWindow.postMessage({
action: 'cancelCoverVideo'
})
}
}}
/>