ad-view.vue 775 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <template>
  2. <view :style="{display: isShow ? 'block' : 'none'}" class="ad-view">
  3. <ad :unit-id="unitId" :ad-intervals="adIntervals" :ad-type="adType" @error="onerror" @load="onload"></ad>
  4. </view>
  5. </template>
  6. <script>
  7. export default {
  8. name:"ad-view",
  9. props: {
  10. // 广告id
  11. unitId: {
  12. type: String,
  13. default: ""
  14. },
  15. // 广告自动刷新时间
  16. adIntervals: {
  17. type: String,
  18. default: '100'
  19. },
  20. adType: {
  21. type: String,
  22. default: 'banner'
  23. }
  24. },
  25. data() {
  26. return {
  27. isShow: true
  28. };
  29. },
  30. methods: {
  31. onload(e) {
  32. this.isShow = true
  33. },
  34. onerror(e) {
  35. this.isShow = false
  36. }
  37. }
  38. }
  39. </script>
  40. <style>
  41. // banner广告
  42. .ad-view {
  43. overflow: hidden;
  44. border-radius: 20rpx;
  45. margin-top: 28rpx;
  46. }
  47. </style>