1 回答

TA貢獻(xiàn)1817條經(jīng)驗(yàn) 獲得超6個(gè)贊
給個(gè)忠告,下次提問(wèn)的時(shí)候,貼出來(lái)的代碼一定要排好版,不然看著這么亂的代碼,回答的心情都沒(méi)了。已經(jīng)手動(dòng)幫你重新排版了下代碼。
說(shuō)正題。
Element UI里的 popover 除了可以使用 v-popover
來(lái)綁定外,還有另一種方式來(lái)實(shí)現(xiàn),如果你稍微認(rèn)真看文檔,肯定能看到下面圖中的內(nèi)容。
圖中說(shuō)到的 slot=reference 就可以被利用起來(lái)。像你問(wèn)題中的代碼,就可以這樣寫(xiě)。
<template slot-scope="scope">
<el-popover placement="top" width="160" trigger="click">
<el-input v-model="scope.row.quantity"></el-input>
<div style="margin-top:10px">
<el-button size="mini" style="float:left"
@click="cancelChange">取消</el-button>
<el-button size="mini" type="primary"
style="float:right"
@click="confirmChange(scope.$index, cart_list)">確認(rèn)</el-button>
</div>
<el-button slot="reference" type="text" style="width:40px">
{{scope.row.quantity}}
</el-button>
</el-popover>
</template>
添加回答
舉報(bào)