init
This commit is contained in:
24
xhs-mini-demos/api-case/memory-warn/memory-warn.css
Normal file
24
xhs-mini-demos/api-case/memory-warn/memory-warn.css
Normal file
@@ -0,0 +1,24 @@
|
||||
.page-section {
|
||||
margin-top: 100px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 100%;
|
||||
padding: 0 25px;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
.page-body-title {
|
||||
font-size: 30px;
|
||||
line-height: 100px;
|
||||
}
|
||||
.page-body-text {
|
||||
color: #bbb;
|
||||
font-size: 14px;
|
||||
line-height: 20px;
|
||||
margin: 0 0 50px 0;
|
||||
text-align: center;
|
||||
}
|
||||
.page-body-button {
|
||||
width: 100%;
|
||||
}
|
||||
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);
|
||||
}
|
||||
},
|
||||
});
|
||||
7
xhs-mini-demos/api-case/memory-warn/memory-warn.json
Normal file
7
xhs-mini-demos/api-case/memory-warn/memory-warn.json
Normal file
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"navigationBarTitleText": "memory-warn",
|
||||
"usingComponents": {
|
||||
"showbox": "../../common/component/showbox/index",
|
||||
"box": "../../common/component/container/index"
|
||||
}
|
||||
}
|
||||
13
xhs-mini-demos/api-case/memory-warn/memory-warn.xhsml
Normal file
13
xhs-mini-demos/api-case/memory-warn/memory-warn.xhsml
Normal file
@@ -0,0 +1,13 @@
|
||||
<view class="container">
|
||||
<showbox title="默认">
|
||||
<box>
|
||||
<view>
|
||||
<text>响应:{{value}}</text>
|
||||
<text>数组长度:{{memory.length}}</text>
|
||||
<button bindtap="bindSubscribe">订阅内存告警</button>
|
||||
<button bindtap="bindUnSubscribe">取消订阅</button>
|
||||
<button bindtap="bindMemory">点击按钮,消耗内存</button>
|
||||
</view>
|
||||
</box>
|
||||
</showbox>
|
||||
</view>
|
||||
Reference in New Issue
Block a user