Files
padui-home/src/components/abnormal/iconAndText.vue
T
2023-04-14 01:07:19 +08:00

39 lines
895 B
Vue

<script setup lang="ts" name="IconAndText">
import { computed } from "vue";
const props = defineProps<{
icon?: string;
text?: string;
width?: number;
height?: number;
}>();
const defaultIcon = new URL("../../assets/svg/failed.svg", import.meta.url).href;
const defaultText = "抱歉,出现意外错误了";
const viewportWidth = 375;
const unit = "vw";
const pxToVw = (val:number) => {
return viewportWidth/100 * val + unit;
};
const iconStyle = computed(() => {
let str = "";
if (props.width) str += "width:" + pxToVw(props.width);
if (props.height) {
str += props.width ? ";" : "";
str += "height:" + pxToVw(props.height);
}
return str;
});
</script>
<template>
<div class="xtbg-tips-page-image" :style="iconStyle">
<img :src="icon || defaultIcon">
</div>
<div class="xtbg-tips-page-text">
<p>{{ text || defaultText }}</p>
</div>
</template>