七猫免费小说去广告版
107.13MB · 2025-09-29
首先我的理念代码优不优秀
下面这代码有问题嘛,其实是有的,因为写的时候相互的依赖关系,太耦合
<!-- flow buttons -->
<flow-op-btns ref="flowOp" v-if="flowButtons.length != 0 && accessHandle"
:buttons="flowButtons"
@ajaxBegin="flowAjaxBeginHandle"
@ajaxEnd="flowAjaxEndHandle"
@printPreview="handlePrintPreview"
@save="save"
@iKnow="iKnow"
@submit="submit"
@recall="recall"
>
<template v-if="flowButtons.includes('printPreview')">
<t-button
class="border-0 iconfont cmccui-hr-xiazai"
@click="downloadUnsignedCertificate">
下载未签章证明
</t-button>
<t-button
v-if="isShowSignedCertificate"
class="border-0 iconfont cmccui-hr-xiazai"
@click="downloadSignedCertificate">
下载已签章证明
</t-button>
</template>
</flow-op-btns>
<template>
<!-- flow buttons -->
<flow-op-btns ref="flowOp" v-if="flowButtons.length != 0 && accessHandle"
:buttons="flowButtons"
@ajaxBegin="flowAjaxBeginHandle"
@ajaxEnd="flowAjaxEndHandle"
@printPreview="handlePrintPreview"
@save="save"
@iKnow="iKnow"
@submit="submit"
@recall="recall"
>
<template v-if="showSignBtnList">
<t-button
class="border-0 iconfont cmccui-hr-xiazai"
@click="downloadUnsignedCertificate">
下载未签章证明
</t-button>
<t-button
v-if="isShowSignedCertificate"
class="border-0 iconfont cmccui-hr-xiazai"
@click="downloadSignedCertificate">
下载已签章证明
</t-button>
</template>
</flow-op-btns>
</template>
export defautl {
computed: {
showPrintPreview() {
return this.userInfo.roleCodeList.includes(`previewRoleCode`)
},
showSignBtnList() {
return this.showPrintPreview
},
}
}
我们用计算属性来将flowButtons.includes('printPreview')替换了
减少冗余的依赖关系
export defautl {
computed: {
showPrintPreview() {
return this.userInfo.roleCodeList.includes(`previewRoleCode`)
},
showSignBtnList() {
return this.userInfo.roleCodeList.includes(`signRoleCode`)
},
}
}
现在依赖关系 roleCodeList -> showSignBtnList 至此依赖关系十分清晰