提交 467abdea 编写于 作者: DCloud-WZF's avatar DCloud-WZF 💬

feat: getApp

上级 43c39f79
......@@ -35,6 +35,12 @@ export default {
console.log('App LastPageBackPress')
return null
},
methods: {
increasetLifeCycleNum() {
setLifeCycleNum(state.lifeCycleNum + 100)
console.log('App increasetLifeCycleNum')
}
}
}
</script>
......
......@@ -4,8 +4,9 @@ describe('getApp', () => {
it('getApp', async () => {
const page = await program.navigateTo(PAGE_PATH)
await page.waitFor(1000)
await page.callMethod('_getApp')
const data = await page.data()
expect(data.checked).toBe(true)
const oldData = await page.data()
await page.callMethod('_increasetLifeCycleNum')
const newData = await page.data()
expect(newData.lifeCycleNum - oldData.lifeCycleNum).toBe(100)
})
})
<template>
<view>
<page-head title="getApp"></page-head>
<button @click="_getApp">getApp</button>
<view class="uni-padding-wrap">
<button @click="_increasetLifeCycleNum">increase lifeCycleNum</button>
<text class="uni-common-mt">lifeCycleNum: {{ lifeCycleNum }}</text>
</view>
</view>
</template>
<script>
export default {
<script lang="ts">
import { state } from '@/store/index.uts'
export default {
data() {
return {
checked: false
lifeCycleNum: 0,
}
},
onReady() {
this.lifeCycleNum = state.lifeCycleNum
},
methods: {
_getApp: function () {
// const app = getApp()
this.checked = true
}
}
}
_increasetLifeCycleNum: function () {
const app = getApp()
app.increasetLifeCycleNum()
this.lifeCycleNum = state.lifeCycleNum
},
},
}
</script>
......@@ -51,7 +51,6 @@
{
name: "getApp",
url: "get-app",
enable: false
},
{
name: "getCurrentPages",
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册