other components... (2)
This commit is contained in:
3
src/components/CMyImg/CMyImg.scss
Executable file
3
src/components/CMyImg/CMyImg.scss
Executable file
@@ -0,0 +1,3 @@
|
||||
.climg {
|
||||
border-radius: 5px;
|
||||
}
|
||||
52
src/components/CMyImg/CMyImg.ts
Executable file
52
src/components/CMyImg/CMyImg.ts
Executable file
@@ -0,0 +1,52 @@
|
||||
import { defineComponent, ref, onMounted } from 'vue'
|
||||
import { tools } from '@store/Modules/tools'
|
||||
|
||||
export default defineComponent({
|
||||
name: 'CMyImg',
|
||||
props: {
|
||||
src: {
|
||||
type: String,
|
||||
required: true,
|
||||
},
|
||||
alt: {
|
||||
type: String,
|
||||
required: true,
|
||||
default: '',
|
||||
},
|
||||
width: {
|
||||
type: String,
|
||||
required: true,
|
||||
default: '',
|
||||
},
|
||||
},
|
||||
components: {},
|
||||
setup(props) {
|
||||
const mystyle = ref('')
|
||||
|
||||
function mounted() {
|
||||
console.log('mounted')
|
||||
console.log(props.src)
|
||||
|
||||
if (props.width)
|
||||
mystyle.value = 'max-width: ' + props.width + 'px; '
|
||||
else
|
||||
mystyle.value = ''
|
||||
}
|
||||
|
||||
function getalt() {
|
||||
if (props.alt) {
|
||||
return props.alt
|
||||
} else {
|
||||
return tools.getimgFullpathbysize(props.src)
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(mounted)
|
||||
|
||||
return {
|
||||
mystyle,
|
||||
getalt,
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
12
src/components/CMyImg/CMyImg.vue
Executable file
12
src/components/CMyImg/CMyImg.vue
Executable file
@@ -0,0 +1,12 @@
|
||||
<template>
|
||||
<div v-if="src" class="text-center">
|
||||
<q-img :src="src" class="myimg" :style="mystyle" :alt="getalt">
|
||||
</q-img>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts" src="./CMyImg.ts">
|
||||
</script>
|
||||
<style lang="scss" scoped>
|
||||
@import './CMyImg.scss';
|
||||
</style>
|
||||
1
src/components/CMyImg/index.ts
Executable file
1
src/components/CMyImg/index.ts
Executable file
@@ -0,0 +1 @@
|
||||
export {default as CMyImg} from './CMyImg.vue'
|
||||
Reference in New Issue
Block a user