myImage.vue 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. <template>
  2. <view>
  3. <image v-if="isIcon" style="border-radius: 60rpx;" :class="[mymode=='widthFix'?'imageW':'imagev']" :src="showdefault==1?'/static/logo.png':baseUrl+comUrl" :mode="mymode" @error="imageError" @click="myimageclick"></image>
  4. <image v-if="!isIcon" :class="[mymode=='widthFix'?'imageW':'imagev']" :src="showdefault==1?'/static/logo.png':baseUrl+comUrl" :mode="mymode" @error="imageError" @click="myimageclick"></image>
  5. </view>
  6. </template>
  7. :class="[isActive==index?'active':'otherActiveClass']"
  8. <script>
  9. export default {
  10. name:"myImage",
  11. props:{
  12. mysrc: '',
  13. mymode:'',
  14. isIcon:false
  15. },
  16. data() {
  17. return {
  18. defaultImage:'/static/logo.png',
  19. baseUrl:'https://backend.cityexpress168.com.vn/prod-api',
  20. showdefault:0,
  21. comUrl:this.mysrc
  22. };
  23. },
  24. watch: {
  25. mysrc(val){
  26. this.showdefault=0;
  27. this.comUrl = this.mysrc
  28. console.log(this.comUrl);
  29. }
  30. },
  31. methods:{
  32. imageError(){
  33. //this.comUrl = this.defaultImage;//morentup
  34. this.showdefault=1;
  35. },
  36. myimageclick(comUrl){
  37. this.$emit('Emyimageclick',comUrl);
  38. },
  39. },
  40. }
  41. </script>
  42. <style>
  43. .imageW{
  44. margin: 0rpx;
  45. width:100%;
  46. }
  47. .imageH{
  48. margin: 0rpx;
  49. height:100%;
  50. }
  51. .imagev{
  52. width:100%;
  53. height:100%;
  54. }
  55. </style>