小程序端工程代码
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

74 lines
1.2 KiB

  1. <template>
  2. <div
  3. :class="show?'yd-mask g-fix-ios-overflow-scrolling-bug':'yd-mask' "
  4. ref="scrollView"
  5. :style="styles"
  6. >
  7. <slot></slot>
  8. </div>
  9. </template>
  10. <script type="text/babel">
  11. export default {
  12. name: "yd-mask",
  13. data() {
  14. return {
  15. show: this.value
  16. };
  17. },
  18. props: {
  19. value: {
  20. type: Boolean,
  21. default: false
  22. },
  23. bgcolor: {
  24. type: String,
  25. default: "#000"
  26. },
  27. zindex: {
  28. default: 1500
  29. },
  30. opacity: {
  31. default: 0.5
  32. },
  33. animated: {
  34. type: Boolean,
  35. default: true
  36. }
  37. },
  38. computed: {
  39. styles() {
  40. const style = {
  41. "z-index": this.zindex,
  42. "background-color": this.bgcolor
  43. };
  44. if (this.show) {
  45. style["opacity"] = this.opacity;
  46. style["pointer-events"] = "auto";
  47. }
  48. return style;
  49. }
  50. },
  51. mounted() {}
  52. };
  53. </script>
  54. <style lang="less">
  55. @css-prefix: yd;
  56. .@{css-prefix} {
  57. &-mask {
  58. position: fixed;
  59. bottom: 0;
  60. right: 0;
  61. left: 0;
  62. top: 0;
  63. display: flex;
  64. justify-content: center;
  65. align-items: center;
  66. pointer-events: none;
  67. transition: opacity 0.2s ease-in;
  68. opacity: 0;
  69. }
  70. }
  71. </style>