Wechat’s built-in browser will cache index.html, so js, CSS files and other contents are always the name of the last version. However, we have updated the version, js and other names are different, so there will be a 404 problem, resulting in a blank screen

Solution:

Refresh the current page and reload index.html

Json file will be added in /public/ folder. When entering quan Lang E home, it will request a version. Json file, get the current version number, and save it locally. If the requested version number is the same as the local version number, the update will not be performed if they are the same. If they are different, the refresh reload will be performed

Version. json {"version": "v2021.2.4.1"}Copy the code
//main.js import axios from 'axios' function version() { let baseurl = window.location.origin + "/version.json" axios.get(baseurl) .then(function (response) { console.log("response", response) if (localStorage.hasOwnProperty("version")) { if (localStorage.getItem("version") ! = response.version) { localStorage.setItem("version", response.version) window.location.reload(); } } else { localStorage.setItem("version", response.version) window.location.reload(); } }) .catch(function (error) { console.log(error); }); } prototype.$version = version //app.vue mountedCopy the code