v-for调用函数
2024年1月25日小于 1 分钟约 177 字
data对象:
clearItem: [
{
func: "Clear Cookies",
info: "Cookies will be clear. When deleted, most sites will be signed out.",
event: "clearCookies"
},
{
func: "Clear Search History",
info: "Search history that was manually entered and accessed from the browser's search box will be cleared.",
event: "clearSearchCookies"
<!-- more -->
},
{
func: "Clear All Browsing Data",
info: "Clear your browsing history,search history including cookies.",
event: "clearAllBrowsingData"
}
],html
<el-menu-item id = "clearBrowsingData" :key="item.func" class = "clear" v-for="item in clearItem" :style="menuClear">
<template @click="clearData(item.event)" v-slot:title>
<el-button tabindex="1" class="function-style" type="text">
{{item.func}}<br>
<p class="buttonHint">{{item.info}}</p>
</el-button>
</template>
<el-divider class="main_divider"></el-divider>
</el-menu-item>methods里面写入方法
clearData (format) {
this[format]()
},
clearCookies () {
console.log("clearCookies")
},
clearSearchCookies () {
console.log("clearSearchCookies")
},
clearAllBrowsingData () {
console.log("clearAllBrowsingData")
},参考文档
https://blog.csdn.net/Poppy_LYT/article/details/98482207
