In developing H5 projects, it is sometimes necessary to judge the iPhone model and distinguish whether it is iPhone X or not. The implementation is as follows:
methods: {
isIPhoneX() {
let u = navigator.userAgent;
let isIOS = !!u.match(/\(i[^;]+;( U;)?CPU.+Mac OS X/);
if (isIOS) {
if (screen.height == 812 && screen.width == 375) {
//is iphoneX
} else {
//not iphoneX
}
}
}
}
Then set the element height dynamically according to ref, as follows:
methods: {
isIPhoneX() {
let u = navigator.userAgent;
let isIOS = !!u.match(/\(i[^;]+;( U;)?CPU.+Mac OS X/);
if (isIOS) {
if (screen.height == 812 && screen.width == 375) {
//is iphoneX
this.$refs.punchcontent.style.height = "calc(100vh - 114px)"
} else {
//not iphoneX
this.$refs.punchcontent.style.height = "calc(100vh - 80px)"
}
}else{
//android
this.$refs.punchcontent.style.height = "calc(100vh - 80px)"
}
}
}
Note: when the
isIPhoneX() method is called, it needs to be invoked in the mounted method, otherwise the setting height is invalid (the first step is to get the DOM node).
Read More:
- Android’s viewpager slides to determine whether the current stop page is the last page
- It is invalid to submit the content directly after pasting it on the mobile terminal of Vue HTML5 editor
- xcode will continue when iPhone is finished iPhone is busy:Processing symbol files
- Get the height of mobile phone status bar through reflection
- The total row of the Element table entry page is not displayed
- Iphone network data is shared to ubuntu14.04 through ubs, which is a desktop computer and cannot be passed through hotspot
- Inline JavaScript is not enabled. Is it set in your options?
- After node.js is installed, use the instruction node version in vscode to show that it is not an external or internal instruction. The solution is as follows:
- iPhone on Windows 10: “Device is unreachable” SOLVED [Debug]
- Android get screen width and height and get control width and height
- Vue3 uses element plus package to solve the problem of occasionally disordered code on the icon after it goes online
- You set the variable “no_check_targets“ here and it was unused before it went out of scope.
- Android gets the height and width of the screen
- Element ‘dependency‘ cannot have character [children], because the type‘s content type is element-on
- Writing to settings when appium of Xiaomi mobile phone and oppo mobile phone starts requires:android.permission.WRITE_ SECURE_ SETTINGS
- Solutions to the problem that Ubuntu is stuck when copying large files and can’t mount mobile hard disk normally
- “ XX.app ”It is damaged and cannot be opened. You should move it to the wastebasket.
- Add a new springboot, and it will appear unable to read meta data for class when it is dependent
- The requested page cannot be accessed because the related configuration data for the page is invalid
- When a system is deployed on weblogic12.2.1.3, it reports an error “IllegalStateException zip file closed”. When it is deployed on weblogic12.2.1.2, it does not report an error and can be accessed normally.