ji.vue
945 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
<template>
<span v-if="imgUrl==0">
十级
</span>
<span v-else>
<el-image :src="imgUrl" style="width: 70px;" />
<!-- {{ szToHz(levelForImg) }}级-->
</span>
</template>
<script setup>
// import { szToHz } from '@/utils/ruoyi'
import { watch, ref } from 'vue'
const imgUrl = ref('0')
const props = defineProps({
level: {
type: String,
default: null
}
})
// const levelForImg = computed(() => {
// const temp = parseInt(props.level || '0')
// if (temp > 0 && temp < 10) {
// return temp
// } else {
// return 0
// }
// })
watch(() => props.level, (newV) => {
if (newV > 0 && newV < 10) {
imgUrl.value = `/img/ji/${newV}.png`
} else {
imgUrl.value = '0'
}
}, { deep: true, immediate: true })
// imgUrl.value = new URL(`/src/assets/images/ji/${levelForImg.value}.png`, import.meta.url).href
// imgUrl.value = `/img/ji/${levelForImg.value}.png`
</script>
<style scoped>
</style>