W3Cschool
恭喜您成為首批注冊(cè)用戶(hù)
獲得88經(jīng)驗(yàn)值獎(jiǎng)勵(lì)
Popover 的屬性與 Tooltip 很類(lèi)似,它們都是基于Popper.js
開(kāi)發(fā)的,因此對(duì)于重復(fù)屬性,請(qǐng)參考 Tooltip 的文檔,在此文檔中不做詳盡解釋。
trigger
屬性用于設(shè)置何時(shí)觸發(fā) Popover ,提供三種觸發(fā)方式:hover
, click
和 focus
。
render() {
return (
<div>
<Popover placement="top-start" title="標(biāo)題" width="200" trigger="hover" content="這是一段容,這是一段容,這是一段容,這是一段容。">
<Button>hover 激活</Button>
</Popover>
<Popover placement="bottom" title="標(biāo)題" width="200" trigger="click" content="這是一段容,這是一段容,這是一段容,這是一段容。">
<Button>click 激活</Button>
</Popover>
<Popover placement="right" title="標(biāo)題" width="200" trigger="focus" content="這是一段容,這是一段容,這是一段容,這是一段容。">
<Button>focus 激活</Button>
</Popover>
</div>
)
}
可以在 Popover 中嵌套多種類(lèi)型信息,以下為嵌套表格的例子。
利用分發(fā)取代content
屬性
constructor(props){
super(props);
this.table = {
columns: [
{
label: "日期",
prop: "date",
width: 150
},
{
label: "姓名",
prop: "name",
width: 100
},
{
label: "地址",
prop: "address",
width: 300
}
],
data: [{
date: '2016-05-02',
name: '王小虎',
address: '上海市普陀區(qū)金沙江路 1518 弄'
}, {
date: '2016-05-04',
name: '王小虎',
address: '上海市普陀區(qū)金沙江路 1517 弄'
}, {
date: '2016-05-01',
name: '王小虎',
address: '上海市普陀區(qū)金沙江路 1519 弄'
}, {
date: '2016-05-03',
name: '王小虎',
address: '上海市普陀區(qū)金沙江路 1516 弄'
}]
}
}
render() {
return (
<Popover placement="right" title="標(biāo)題" width="400" trigger="click" content={(
<Table
style={{width: '100%'}}
stripe={true}
columns={this.table.columns}
data={this.table.data} />
)}>
<Button>click 激活</Button>
</Popover>
)
}
當(dāng)然,你還可以嵌套操作,這相比 Dialog 更為輕量:
constructor(props){
super(props);
this.state = {};
}
onDismiss() {
this.setState({
visible: false
});
}
render() {
return (
<Popover placement="top" width="160" trigger="click" visible={this.state.visible} content={(
<div>
<p>這是一段內(nèi)容這是一段內(nèi)容確定刪除嗎?</p>
<div style={{textAlign: 'right', margin: 0}}>
<Button size="mini" type="text" onClick={this.onDismiss.bind(this)}>取消</Button>
<Button type="primary" size="mini" onClick={this.onDismiss.bind(this)}>確定</Button>
</div>
</div>
)}>
<Button>刪除</Button>
</Popover>
)
}
參數(shù) | 說(shuō)明 | 類(lèi)型 | 可選值 | 默認(rèn)值 |
---|---|---|---|---|
trigger | 觸發(fā)方式 | String | click/focus/hover | click |
title | 標(biāo)題 | String | — | — |
content | 顯示的內(nèi)容,也可以通過(guò) slot 傳入 DOM |
String | — | — |
width | 寬度 | String, Number | — | 最小寬度 150px |
placement | 出現(xiàn)位置 | String | top/top-start/top-end/bottom/bottom-start/bottom-end/left/left-start/left-end/right/right-start/right-end | bottom |
visible | 狀態(tài)是否可見(jiàn) | Boolean | — | false |
transition | 定義漸變動(dòng)畫(huà) | String | — | fade-in-linear |
visibleArrow | 是否顯示 Tooltip 箭頭 | Boolean | — | true |
popperClass | 為 popper 添加類(lèi)名 | String | - | - |
Copyright©2021 w3cschool編程獅|閩ICP備15016281號(hào)-3|閩公網(wǎng)安備35020302033924號(hào)
違法和不良信息舉報(bào)電話(huà):173-0602-2364|舉報(bào)郵箱:jubao@eeedong.com
掃描二維碼
下載編程獅App
編程獅公眾號(hào)
聯(lián)系方式:
更多建議: