index.vue 3.0 KB

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