问题就是如果App卸载会导致缓存数据丢失,这个时候我在考虑能不能把数据保存到手机中,这样应用在卸载之后就不会导致数据丢失,在重新打开App的时候对手机数据文件进行校验,来判断是应用内升级还是应用外升级,代码如下:
//提交服务器设置
submitSetURL: function() {
let _this = this;
if (this.serverURL == ‘’) {
this.$refs.loginToast.show({
title: ‘服务器地址不能为空!’,
type: ‘warning’,
});
} else {
//服务器链接
Any.wsUrl = “wss://” + _this.serverURL + “/talkws”;
Any.httpUrl = “https://” + _this.serverURL + “/index.php/admin/”;
// 请求本地文件系统对象,将服务器链接写入文件进行本地化保存
plus.io.requestFileSystem(
plus.io.PUBLIC_DOCUMENTS, // 程序公用文档目录常量
fs => {
// 创建或打开文件, fs.root是根目录操作对象,直接fs表示当前操作对象
fs.root.getFile(‘serverURL.json’, {
create: true // 文件不存在则创建
}, fileEntry => {
// 文件在手机中的路径
//console.log(fileEntry