container.vue 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. <template>
  2. <view class="container"
  3. :style="mixinVariableStr"
  4. :class="{
  5. 'safe-area-top':safeAreaTop,
  6. 'safe-area-bottom':safeAreaBottom,
  7. 'scroll':scroll
  8. }"
  9. >
  10. <slot name="default"></slot>
  11. </view>
  12. </template>
  13. <script>
  14. import cssVariable from "../mixin/css-variable.js";
  15. export default {
  16. mixins:[cssVariable],
  17. props:{
  18. zIndex:{
  19. type: Number | String,
  20. default:"99"
  21. },
  22. safeAreaTop:{
  23. type: Boolean,
  24. default:false
  25. },
  26. safeAreaBottom:{
  27. type: Boolean,
  28. default:true
  29. },
  30. scroll:{
  31. type: Boolean,
  32. default:false
  33. }
  34. },
  35. computed:{
  36. },
  37. data() {
  38. return {
  39. privateVariableKeys:["zIndex"],
  40. };
  41. },
  42. created() {
  43. }
  44. }
  45. </script>
  46. <style lang="scss" scoped>
  47. @import "../libs/global.scss";
  48. .safe-area-top{
  49. padding-top: var(--status-bar-height);
  50. }
  51. .safe-area-bottom{
  52. padding-bottom: 0;
  53. padding-bottom: constant(safe-area-inset-bottom);
  54. padding-bottom: env(safe-area-inset-bottom);
  55. }
  56. .container{
  57. position: fixed;
  58. top: 0;
  59. top:var(--window-top);
  60. right: 0;
  61. bottom: 0;
  62. bottom: var(--window-bottom);
  63. left: 0;
  64. width: auto;
  65. height: auto;
  66. z-index: var(--zIndex);
  67. background-color: var(--background);
  68. overflow: hidden;
  69. &.scroll{
  70. overflow-y: auto;
  71. }
  72. }
  73. </style>