Popover 的屬性與 Tooltip 很類似,它們都是基于Vue-popper開發(fā)的,因此對于重復(fù)屬性,請參考 Tooltip 的文檔,在此文檔中不做詳盡解釋。
trigger屬性用于設(shè)置何時觸發(fā) Popover,支持四種觸發(fā)方式:hover,click,focus 和 manual。對于觸發(fā) Popover 的元素,有兩種寫法:使用 slot="reference" 的具名插槽,或使用自定義指令v-popover指向 Popover 的索引ref。
<template>
<el-popover
placement="top-start"
title="標(biāo)題"
width="200"
trigger="hover"
content="這是一段內(nèi)容,這是一段內(nèi)容,這是一段內(nèi)容,這是一段內(nèi)容。">
<el-button slot="reference">hover 激活</el-button>
</el-popover>
<el-popover
placement="bottom"
title="標(biāo)題"
width="200"
trigger="click"
content="這是一段內(nèi)容,這是一段內(nèi)容,這是一段內(nèi)容,這是一段內(nèi)容。">
<el-button slot="reference">click 激活</el-button>
</el-popover>
<el-popover
ref="popover"
placement="right"
title="標(biāo)題"
width="200"
trigger="focus"
content="這是一段內(nèi)容,這是一段內(nèi)容,這是一段內(nèi)容,這是一段內(nèi)容。">
</el-popover>
<el-button v-popover:popover>focus 激活</el-button>
<el-popover
placement="bottom"
title="標(biāo)題"
width="200"
trigger="manual"
content="這是一段內(nèi)容,這是一段內(nèi)容,這是一段內(nèi)容,這是一段內(nèi)容。"
v-model="visible">
<el-button slot="reference" @click="visible = !visible">手動激活</el-button>
</el-popover>
</template>
<script>
export default {
data() {
return {
visible: false
};
}
};
</script>