Skip to content

Commit

Permalink
修改svgIcon组件的写法为ts
Browse files Browse the repository at this point in the history
  • Loading branch information
FU-design committed Jul 31, 2024
1 parent 6b22e51 commit d3feaa3
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 39 deletions.
10 changes: 5 additions & 5 deletions bigtop-manager-ui/src/assets/images/svg/start.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
57 changes: 23 additions & 34 deletions bigtop-manager-ui/src/components/svg-icon/svg-icon.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,38 +17,27 @@
~ under the License.
-->

<script>
import { defineComponent, computed } from 'vue'
export default defineComponent({
name: 'SvgIcon',
props: {
prefix: {
type: String,
default: 'icon'
},
name: {
type: String,
required: true
},
color: {
type: String,
default: '#000'
},
className: {
type: String,
default: ''
}
},
setup(props) {
const symbolId = computed(() => `#${props.prefix}-${props.name}`)
const svgClass = computed(() => {
if (props.className) {
return `svg-icon ${props.className}`
}
return 'svg-icon'
})
return { symbolId, svgClass }
<script setup lang="ts">
import { computed } from 'vue'

interface SvgIconProps {
prefix: string
name: string
color: string
className: string
}

const props = withDefaults(defineProps<SvgIconProps>(), {
prefix: 'icon',
color: '#000'
})

const symbolId = computed(() => `#${props.prefix}-${props.name}`)
const svgClass = computed(() => {
if (props.className) {
return `svg-icon ${props.className}`
}
return 'svg-icon'
})
</script>

Expand All @@ -60,10 +49,10 @@

<style lang="scss" scoped>
.svg-icon {
height: 1em;
width: 1em;
height: 1.2em;
width: 1.2em;
margin-right: 6px;
vertical-align: -0.15em;
vertical-align: -0.25em;
overflow: hidden;
}
</style>

0 comments on commit d3feaa3

Please sign in to comment.