mand-mobile/components/icon/index.vue

62 lines
996 B
Vue
Raw Normal View History

2018-03-26 16:04:04 +08:00
<template>
<svg
v-if="name"
class="md-icon"
:class="[`md-icon-${name}`, size]"
2018-09-03 10:55:46 +08:00
:style="{fill: color}"
@click="$emit('click', $event)"
>
2018-03-26 16:04:04 +08:00
<use :xlink:href="`#${name}`"/>
</svg>
</template>
<script> import loadSprite from './load-spirte'
export default {
name: 'md-icon',
props: {
name: {
type: String,
default: '',
},
size: {
type: String,
default: 'md',
},
color: {
type: String,
default: '',
},
},
mounted() {
loadSprite()
},
}
</script>
<style lang="stylus">
.md-icon
background-size contain
fill currentColor
2018-09-28 17:46:34 +08:00
-webkit-backface-visibility hidden
transform translateZ(0) scale(1.0, 1.0)
2018-03-26 16:04:04 +08:00
// size
&.xss
width icon-size-xxs
height icon-size-xxs
&.xs
width icon-size-xs
height icon-size-xs
&.sm
width icon-size-sm
height icon-size-sm
&.md
width icon-size-md
height icon-size-md
&.lg
width icon-size-lg
height icon-size-lg
2018-09-28 17:46:34 +08:00
</style>