c-icon.vue 615 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <template>
  2. <view class="image-wrap" :style="{width: torpx + 'px', height: torpx + 'px'}" >
  3. <image v-if="src" :src="src" mode="aspectFit"></image>
  4. </view>
  5. </template>
  6. <script>
  7. export default {
  8. name:"c-icon",
  9. data() {
  10. return {
  11. };
  12. },
  13. props: {
  14. src: {
  15. type: String,
  16. default: ''
  17. },
  18. size: {
  19. type: Number | String,
  20. default: 40
  21. }
  22. },
  23. computed:{
  24. torpx(){
  25. return uni.upx2px(this.size)
  26. }
  27. }
  28. }
  29. </script>
  30. <style lang="scss">
  31. .image-wrap{
  32. display: inline-flex;
  33. align-items: center;
  34. font-size: 0;
  35. image{
  36. width: 100%;
  37. height: 100%;
  38. }
  39. }
  40. </style>