index.vue 2.8KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. <template>
  2. <uni-shadow-root class="vant-toast-index"><van-overlay v-if="mask || forbidClick" :show="show" :mask="mask" :z-index="zIndex"></van-overlay>
  3. <van-transition :show="show" :custom-style="'z-index: '+(zIndex)" custom-class="van-toast__container">
  4. <view :class="'van-toast van-toast--'+(type === 'text' ? 'text' : 'icon')+' van-toast--'+(position)" @touchmove.stop.prevent="noop">
  5. <text v-if="type === 'text'">{{ message }}</text>
  6. <block v-else>
  7. <van-loading v-if="type === 'loading'" color="white" :type="loadingType" custom-class="van-toast__loading"></van-loading>
  8. <van-icon v-else class="van-toast__icon" :name="type"></van-icon>
  9. <text v-if="message" class="van-toast__text">{{ message }}</text>
  10. </block>
  11. <slot></slot>
  12. </view>
  13. </van-transition></uni-shadow-root>
  14. </template>
  15. <script>
  16. import VanIcon from '../icon/index.vue'
  17. import VanLoading from '../loading/index.vue'
  18. import VanOverlay from '../overlay/index.vue'
  19. import VanTransition from '../transition/index.vue'
  20. global['__wxVueOptions'] = {components:{'van-icon': VanIcon,'van-loading': VanLoading,'van-overlay': VanOverlay,'van-transition': VanTransition}}
  21. global['__wxRoute'] = 'vant/toast/index'
  22. import { VantComponent } from '../common/component';
  23. VantComponent({
  24. props: {
  25. show: Boolean,
  26. mask: Boolean,
  27. message: String,
  28. forbidClick: Boolean,
  29. zIndex: {
  30. type: Number,
  31. value: 1000
  32. },
  33. type: {
  34. type: String,
  35. value: 'text'
  36. },
  37. loadingType: {
  38. type: String,
  39. value: 'circular'
  40. },
  41. position: {
  42. type: String,
  43. value: 'middle'
  44. }
  45. },
  46. methods: {
  47. // for prevent touchmove
  48. noop() { }
  49. }
  50. });
  51. export default global['__wxComponents']['vant/toast/index']
  52. </script>
  53. <style platform="mp-weixin">
  54. @import '../common/index.css';.van-toast{display:-webkit-flex;display:flex;color:#fff;font-size:14px;line-height:20px;border-radius:4px;word-break:break-all;-webkit-align-items:center;align-items:center;-webkit-flex-direction:column;flex-direction:column;-webkit-justify-content:center;justify-content:center;box-sizing:initial;background-color:rgba(51,51,51,.88);white-space:pre-wrap}.van-toast__container{position:fixed;top:50%;left:50%;max-width:70%;width:-webkit-fit-content;width:fit-content;-webkit-transform:translate(-50%,-50%);transform:translate(-50%,-50%)}.van-toast--text{padding:8px 12px;min-width:96px}.van-toast--icon{width:90px;padding:15px;min-height:90px}.van-toast--icon .van-toast__icon{font-size:48px}.van-toast--icon .van-toast__text{padding-top:5px}.van-toast__loading{margin:10px 0}.van-toast--top{-webkit-transform:translateY(-30vh);transform:translateY(-30vh)}.van-toast--bottom{-webkit-transform:translateY(30vh);transform:translateY(30vh)}
  55. </style>