尽量使用剪头函数
uni.setStorage({
key: 'storage_key',
data: 'hello',
success: function () {
this.title = "改变3";
}
});
改为
uni.setStorage({
key: 'storage_key',
data: 'hello',
success:() => {
this.title = "改变3";
}
});
第二 在api外面使用单独赋值
//可以发现这样操作就可以解决作用域问题
changeTitle3(){
//赋值
var me = this;
uni.setStorage({
key: 'storage_key',
data: 'hello',
success: function () {
me.title = "改变标题3";
}
});
},