// 读取客户端配置文件
getConfigContent(){
let result = ""
//创建对象实例
try {
let fileSystemObj = new ActiveXObject("Scripting.FileSystemObject")
if (fileSystemObj.FileExists("c://configure.txt")) {
// 打开文件
let fileTxt = fileSystemObj.OpenTextFile("c://configure.txt")
// 读取文件一行内容到字符串
result = fileTxt.ReadLine()
// 关闭文件
fileTxt.Close()
}
} catch (e) {
// 此处使用的element的消息提示组件
this.$message.error(
"请使用ie11浏览器,或请设置浏览器的安全设置,启用对未标记为可安全执行脚本的ActiveX控件初始化并执行脚本!",
)
}
return result
}
android安卓手机微信浏览器偶尔也有这样的问题,经过多次调试,发现是微信浏览器缓存了渲染页面,没有重新渲染页面,导致window.onload中JS无法执行。经过以上分析判断,给出的解决方案就是,如果使用了缓存,自动重载页面。以下是JS代码解决方案:
window.onpageshow = function(event) {
if (event.persisted) {
window.location.reload()
}
}
或者下方代码:
var isPageHide = false
window.addEventListener('pageshow', function () {
if (isPageHide) {
window.location.reload()
}
})
window.addEventListener('pagehide', function () {
isPageHide = true
})
html头部处理缓存信息:
扩展说明:
pageshow:
当一条会话历史记录被执行的时候将会触发页面显示(pageshow)事件。(这包括了后退/前进按钮操作,同时也会在onload 事件触发后初始化页面时触发)