Blame view

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