前端工作小结28-按钮封装

<template>
<div>
<div class="box" :style="{'backgroundColor':bgcolor,'margin':margin}">
<div class="btnbox">
<p v-for="count in Number(this.count)" :class="showbtn?'morebtn':'btn'" @click="confirm(count)"
:style="{'backgroundColor':'#'+bgobj[count-1],'width':Wobj[count-1]+'px',
'height':Harr[count-1]+'px','line-height':Harr[count-1]+'px','color':'#'+fontcolor[count-1]}">{{textarr[count-1]}}</p >
</div>
</div>
</div>
</template>
<script>
export default {
name:"gogift",
props:["textarr","bgcolor","margin","margin","count","bgarr","widarr","Harr","fontcolor"],
data(){
return{
showbtn:"",
le:"#399",
bgobj:{},
Wobj:{}
}
},
methods:{
confirm(count){
this.$emit("combtn",count)
}
},
created() {
for(var key in this.bgarr){
if(this.bgarr[key]==""){
this.bgarr[key]="585858"
}else{
this.bgobj[key]=this.bgarr[key]
}
}
for(var key in this.widarr){
if(this.widarr[key]==""){
this.Wobj[key]="90"
}else{
this.Wobj[key]=this.widarr[key]
}
}
if(this.count){
this.showbtn=true
}else{
this.showbtn=false
}
}
}
</script>
<style scoped>
.box{
width: 89.4%;
display: flex;
margin: 5.3%;
}
.morebtn{
font-family: "PingFang SC-Regular";
border-radius: 0.22rem;
width: 1rem;
height: 0.45rem;
line-height: 0.45rem;
font-size: 0.16rem;
color: #FFFFFF;
letter-spacing: 0.0019rem;
text-align: center;
}
.btnbox{
width: 100%;
display: flex;
align-items: center;
justify-content: space-around;
}
</style>

 

posted @   前端导师歌谣  阅读(16)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 分享一个免费、快速、无限量使用的满血 DeepSeek R1 模型,支持深度思考和联网搜索!
· 基于 Docker 搭建 FRP 内网穿透开源项目(很简单哒)
· ollama系列01:轻松3步本地部署deepseek,普通电脑可用
· 25岁的心里话
· 按钮权限的设计及实现
点击右上角即可分享
微信分享提示