作用
此随笔记录我人生中所有自己写出来的组件样式
图片加文字组件
<template>
<div class="set_img">
<el-container>
<el-aside width="300px">
<p class="set_img_p">弹框一:</p>
<div class="set_img_bk">
<el-upload class="avatar-uploader custom-uploader"
action="https://jsonplaceholder.typicode.com/posts/" :show-file-list="false"
:on-success="handleAvatarSuccess" :before-upload="beforeAvatarUpload">
<img v-if="imageUrl" :src="imageUrl" class="avatar">
<i v-else class="el-icon-plus avatar-uploader-icon"></i>
</el-upload>
</div>
</el-aside>
<el-main>
<div class="set_img_attribute">
<p>关闭方式:</p>
<el-checkbox style="margin-left: 6%;margin-top: 6%;" v-model="checked1">5秒后自动关闭</el-checkbox>
<el-checkbox v-model="checked2">手动关闭</el-checkbox>
<p style="margin-top: 6%;">弹出时效:</p>
<el-radio style="margin-left: 6%;margin-top: 6%;" v-model="radio" label="1">默认弹窗5天</el-radio>
<el-radio v-model="radio" label="2">播放至</el-radio>
<el-date-picker style="width: 30%;" v-model="value1" type="date" placeholder="请选择日期">
</el-date-picker><br>
<el-button style="margin-top: 10%;margin-right: 15%;float: right;" type="primary">保存</el-button>
</div>
</el-main>
</el-container>
</div>
</template>
<script>
export default {
name: 'PopupBox',
data() {
return {
//单选框
value1:'',
radio: '1',
//多选框
checked1: true,
checked2: true,
imageUrl: ''
};
},
methods: {
handleAvatarSuccess(res, file) {
this.imageUrl = URL.createObjectURL(file.raw);
},
beforeAvatarUpload(file) {
const isJPG = file.type === 'image/jpeg';
const isLt2M = file.size / 1024 / 1024 < 2;
if (!isJPG) {
this.$message.error('上传头像图片只能是 JPG 格式!');
}
if (!isLt2M) {
this.$message.error('上传头像图片大小不能超过 2MB!');
}
return isJPG && isLt2M;
}
}
}
</script>
<style scoped>
.set_img_p {
margin-left: 5%;
}
.set_img {
margin-left: 2%;
border: 1px solid rgb(228, 228, 228);
width: 750px;
height: 360px;
}
.set_img_attribute {}
.avatar {
width: 100%;
height: 100%;
display: block;
}
/* .avatar-uploader .el-upload {
border: 1px dashed #1a0e0e;
border-radius: 6px;
cursor: pointer;
position: relative;
overflow: hidden;
} */
.avatar-uploader .el-upload:hover {
border-color: #1c5792;
}
.avatar-uploader-icon {
font-size: 28px;
color: #8c939d;
}
.custom-uploader {
background-color: #f0f0f0;
/* 设置背景颜色 */
padding: 10px;
/* 添加一些内边距 */
border-radius: 5px;
/* 添加圆角 */
border: 1px solid #dcdcdc;
/* 添加边框 */
display: flex;
/* 使用 Flexbox 布局 */
justify-content: center;
/* 水平居中 */
align-items: center;
/* 垂直居中 */
width: 200px;
/* 设置宽度 */
height: 250px;
/* 设置高度 */
margin-left: 10%;
}
</style>
标签:vue,file,img,avatar,uploader,组件,border,大全
From: https://www.cnblogs.com/freps/p/18672960