1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283 |
- <template>
- <div class="img-wrapper">
- <img :src="realImage || defaultImgSrc" alt="" />
- <div v-if="realImage" class="cancel-btn-background" @click="handleCancel">
- <i class="iconfont icon-close"></i>
- </div>
- </div>
- </template>
- <script>
- export default {
- data() {
- return {
- realImage: "",
- };
- },
- props: {
- imgSrc: {
- type: String,
- default: "",
- },
- defaultImgSrc: {
- type: String,
- require: true,
- },
- },
- watch: {
- imgSrc: {
- handler(val) {
- this.realImage = val;
- },
- immediate: true,
- deep: true,
- },
- },
- methods: {
- handleCancel() {
- console.log("select_image-component-cancel");
- this.realImage = "";
- this.$emit("cancel");
- },
- },
- };
- </script>
- <style lang="less" scoped>
- .img-wrapper {
- flex: 0 0 auto;
- position: relative;
- width: 136px;
- height: 136px;
- margin-right: 16px;
- background: #1a1b1d;
- border-radius: 4px;
- border: 1px solid #404040;
- overflow: hidden;
- > img {
- width: 100%;
- height: 100%;
- object-fit: contain;
- }
- > .cancel-btn-background {
- width: 52px;
- height: 52px;
- position: absolute;
- top: -28px;
- right: -28px;
- background: rgba(0, 0, 0, 0.5);
- border-radius: 50%;
- cursor: pointer;
- &:hover {
- color: #fa5555;
- }
- > i {
- font-size: 12px;
- transform: scale(0.8);
- position: absolute;
- left: 9px;
- bottom: 9px;
- }
- }
- }
- </style>
|