index.vue 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. <template>
  2. <uni-shadow-root class="weapp-lib-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 === 'text' || type === 'html') ? 'text' : 'icon')+' 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'] = 'weapp/lib/toast/index'
  23. "use strict";
  24. Object.defineProperty(exports, "__esModule", { value: true });
  25. var component_1 = require("../common/component");
  26. (0, component_1.VantComponent)({
  27. props: {
  28. show: Boolean,
  29. mask: Boolean,
  30. message: String,
  31. forbidClick: Boolean,
  32. zIndex: {
  33. type: Number,
  34. value: 1000,
  35. },
  36. type: {
  37. type: String,
  38. value: 'text',
  39. },
  40. loadingType: {
  41. type: String,
  42. value: 'circular',
  43. },
  44. position: {
  45. type: String,
  46. value: 'middle',
  47. },
  48. },
  49. methods: {
  50. // for prevent touchmove
  51. noop: function () { },
  52. },
  53. });
  54. export default global['__wxComponents']['weapp/lib/toast/index']
  55. </script>
  56. <style platform="mp-weixin">
  57. @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)}
  58. </style>