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.

59 lines
1.5 KiB

4 months ago
  1. <template>
  2. <view
  3. class="u-safe-bottom"
  4. :style="[style]"
  5. :class="[!isNvue && 'u-safe-area-inset-bottom']"
  6. >
  7. </view>
  8. </template>
  9. <script>
  10. import { props } from "./props.js";
  11. import { mpMixin } from '../../libs/mixin/mpMixin';
  12. import { mixin } from '../../libs/mixin/mixin';
  13. import { addStyle, deepMerge, addUnit, sys } from '../../libs/function/index';
  14. /**
  15. * SafeBottom 底部安全区
  16. * @description 这个适配主要是针对IPhone X等一些底部带指示条的机型指示条的操作区域与页面底部存在重合容易导致用户误操作因此我们需要针对这些机型进行底部安全区适配
  17. * @tutorial https://ijry.github.io/uview-plus/components/safeAreaInset.html
  18. * @property {type} prop_name
  19. * @property {Object} customStyle 定义需要用到的外部样式
  20. *
  21. * @event {Function()}
  22. * @example <u-status-bar></u-status-bar>
  23. */
  24. export default {
  25. name: "u-safe-bottom",
  26. mixins: [mpMixin, mixin, props],
  27. data() {
  28. return {
  29. safeAreaBottomHeight: 0,
  30. isNvue: false,
  31. };
  32. },
  33. computed: {
  34. style() {
  35. const style = {};
  36. // #ifdef APP-NVUE || MP-TOUTIAO
  37. // nvue下,高度使用js计算填充
  38. style.height = addUnit(sys().safeAreaInsets.bottom, 'px');
  39. // #endif
  40. return deepMerge(style, addStyle(this.customStyle));
  41. },
  42. },
  43. mounted() {
  44. // #ifdef APP-NVUE
  45. // 标识为是否nvue
  46. this.isNvue = true;
  47. // #endif
  48. },
  49. };
  50. </script>
  51. <style lang="scss" scoped>
  52. .u-safe-bottom {
  53. /* #ifndef APP-NVUE */
  54. width: 100%;
  55. /* #endif */
  56. }
  57. </style>