The content this article brings to you is about the problems and solutions encountered in mobile H5 development. It has certain reference value. Friends in need can refer to it. I hope it will be helpful to you.
WeChat sharing signature error invalid signature
In vue single-page application history mode, WeChat sharing always prompts signature error invalid signature
According to the WeChat official website document, jssdk has been introduced, correct Configure a js secure domain name, and the signature generated by the backend developer is also verified by the WeChat signature tool. However, the custom sharing on the front end always reports a signature error, and there is no way to customize the sharing. If you ensure that there are no problems with the basic configuration, and the signature also passes WeChat Signature tool verification, then it may be a signature error caused by the inconsistency between the URL accessed by the front-end and the URL generated by the background.
If the front-end passes the URL to the back-end through ajax to obtain the signature, then we need to remove the current page' #'hash part of the link, and needs to encodeURIComponent
let url = location.href.split('#')[0]
encodeURIComponent(url)
Normally, this can achieve custom sharing on WeChat, but after the single-page application routing is switched, the IOS side still prompts a signature error, and the Android side has no problem
This is because the view in history mode is switched through pushState, but the IOS WeChat client (the Android client has been repaired) does not support the new H5 feature of pushState, so the routing changes but the WeChat browser obtains The URL has not changed. Copy the link in the upper right corner and find that the URL recorded by WeChat is still the URL when you first entered it. Unless you refresh it manually or refresh it using page jump methods such as window.location, you can get the latest URL
The solution is to record the URL when entering the page. If it is an iOS device, then use this URL to obtain the WeChat signature
router.afterEach(to => {
sessionStorage.setItem('currentUrl',window.location.href)
})
let url = encodeURIComponent(location.href.split('#')[0])
if(system == "iOS" && sessionStorage.getItem('currentUrl')) {
url = encodeURIComponent(sessionStorage.getItem('currentUrl').split('#')[0])
}
At this time, it is correct to use this URL to obtain the WeChat signature. This method is only suitable for For IOS devices, as long as the signed URL is consistent with the URL recorded by WeChat, it will be correct.
Round-trip caching problem
When you click the browser's forward and backward buttons, sometimes the js will not be automatically executed. Specifically in Safari, this has to do with round trip caching (bfcache).
Solution: window.onunload = function(){};
If it is a Vue single-page application and keep-alive is used, the page will not be refreshed. At this time, some interface requests can be made. Place it in the beforeRouteEnter method
IOS does not support the format of new Date("2019-01-01 00:00:00")
This way of writing new Date("2019-01 -01 00:00:00") is supported on the Android side, but not supported on the IOS side, and a NAN error will be reported, so you need to change new Date("2019-01-01 00:00:00") to new Date("2019/01/01 00:00:00") This form
let date = '2019-01-01 00:00:00' date.replace(/\-/g, '/')
WeChat QR code
There may be multiple QR codes on a page, but long press to identify two The QR code can only recognize the last QR code. At this time, we need to control that only one QR code can appear in the visible area of the page.
Cannot be clicked on IOS
span,p, etc. cannot be clicked by default Clicked label, monitoring click event click is invalid in IOS
Solution, add cursor: pointer;
audio audio cannot be played
audio.play() method can be played normally on Android devices , but it cannot be played on the IOS client. After setting the src of audio, we need to add this line of code
audio.load() to load the audio
You can check whether the audio is OK by monitoring the loadeddata method Start playing. Android is set to start playing after the audio is loaded, but there may be a slight delay on the iOS side. At this time, we can get whether the audio has started playing through audio.currentTime. If this value is greater than 0, it means that it has started playing.
300ms delayed response to click event on IOS mobile terminal
Fixed problem
In systems below ios8, when the small keyboard is activated, the position floating problem will occur. The solution is: just Add css style to the outer layer p in the middle part
position:fixed;top:50px; bottom:50px;overflow:scroll;
This article is all over here, there are more other exciting contents You can pay attention to the HTML5 video tutorial column on the PHP Chinese website!
The above is the detailed content of Problems and solutions encountered in mobile H5 development. For more information, please follow other related articles on the PHP Chinese website!
H5 Code: Best Practices for Web DevelopersApr 16, 2025 am 12:14 AMBest practices for H5 code include: 1. Use correct DOCTYPE declarations and character encoding; 2. Use semantic tags; 3. Reduce HTTP requests; 4. Use asynchronous loading; 5. Optimize images. These practices can improve the efficiency, maintainability and user experience of web pages.
H5: The Evolution of Web Standards and TechnologiesApr 15, 2025 am 12:12 AMWeb standards and technologies have evolved from HTML4, CSS2 and simple JavaScript to date and have undergone significant developments. 1) HTML5 introduces APIs such as Canvas and WebStorage, which enhances the complexity and interactivity of web applications. 2) CSS3 adds animation and transition functions to make the page more effective. 3) JavaScript improves development efficiency and code readability through modern syntax of Node.js and ES6, such as arrow functions and classes. These changes have promoted the development of performance optimization and best practices of web applications.
Is H5 a Shorthand for HTML5? Exploring the DetailsApr 14, 2025 am 12:05 AMH5 is not just the abbreviation of HTML5, it represents a wider modern web development technology ecosystem: 1. H5 includes HTML5, CSS3, JavaScript and related APIs and technologies; 2. It provides a richer, interactive and smooth user experience, and can run seamlessly on multiple devices; 3. Using the H5 technology stack, you can create responsive web pages and complex interactive functions.
H5 and HTML5: Commonly Used Terms in Web DevelopmentApr 13, 2025 am 12:01 AMH5 and HTML5 refer to the same thing, namely HTML5. HTML5 is the fifth version of HTML, bringing new features such as semantic tags, multimedia support, canvas and graphics, offline storage and local storage, improving the expressiveness and interactivity of web pages.
What Does H5 Refer To? Exploring the ContextApr 12, 2025 am 12:03 AMH5referstoHTML5,apivotaltechnologyinwebdevelopment.1)HTML5introducesnewelementsandAPIsforrich,dynamicwebapplications.2)Itsupportsmultimediawithoutplugins,enhancinguserexperienceacrossdevices.3)SemanticelementsimprovecontentstructureandSEO.4)H5'srespo
H5: Tools, Frameworks, and Best PracticesApr 11, 2025 am 12:11 AMThe tools and frameworks that need to be mastered in H5 development include Vue.js, React and Webpack. 1.Vue.js is suitable for building user interfaces and supports component development. 2.React optimizes page rendering through virtual DOM, suitable for complex applications. 3.Webpack is used for module packaging and optimize resource loading.
The Legacy of HTML5: Understanding H5 in the PresentApr 10, 2025 am 09:28 AMHTML5hassignificantlytransformedwebdevelopmentbyintroducingsemanticelements,enhancingmultimediasupport,andimprovingperformance.1)ItmadewebsitesmoreaccessibleandSEO-friendlywithsemanticelementslike,,and.2)HTML5introducednativeandtags,eliminatingthenee
H5 Code: Accessibility and Semantic HTMLApr 09, 2025 am 12:05 AMH5 improves web page accessibility and SEO effects through semantic elements and ARIA attributes. 1. Use, etc. to organize the content structure and improve SEO. 2. ARIA attributes such as aria-label enhance accessibility, and assistive technology users can use web pages smoothly.


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

VSCode Windows 64-bit Download
A free and powerful IDE editor launched by Microsoft

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

SublimeText3 Linux new version
SublimeText3 Linux latest version

Dreamweaver CS6
Visual web development tools

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.







