init
This commit is contained in:
42
xhs-mini-demos/api-case/memory-warn/memory-warn.js
Normal file
42
xhs-mini-demos/api-case/memory-warn/memory-warn.js
Normal file
@@ -0,0 +1,42 @@
|
||||
Page({
|
||||
onShareAppMessage() {
|
||||
return {
|
||||
title: 'memory-warn',
|
||||
path: 'package/API/pages/memory-warn/memory-warn',
|
||||
};
|
||||
},
|
||||
|
||||
data: {
|
||||
value: '',
|
||||
memory: [],
|
||||
},
|
||||
resetValue() {
|
||||
this.setData({ value: '' });
|
||||
},
|
||||
bindSubscribe() {
|
||||
this.resetValue();
|
||||
xhs.onMemoryWarning(e => {
|
||||
this.setData({ value: JSON.stringify(e) });
|
||||
});
|
||||
this.setData({ value: '订阅成功' });
|
||||
},
|
||||
bindUnSubscribe() {
|
||||
this.resetValue();
|
||||
xhs.offMemoryWarning(() => {
|
||||
this.setData({ value: '取消成功' });
|
||||
});
|
||||
},
|
||||
bindMemory() {
|
||||
if (this.handle) {
|
||||
clearInterval(this.handle);
|
||||
} else {
|
||||
this.handle = setInterval(() => {
|
||||
const { memory } = this.data;
|
||||
for (let i = 0; i < 100; i++) {
|
||||
memory.push({ name: 'test', age: 20 });
|
||||
}
|
||||
this.setData({ memory });
|
||||
}, 1000);
|
||||
}
|
||||
},
|
||||
});
|
||||
Reference in New Issue
Block a user