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

refactor: 优化 $forceUpdate 示例

上级 db0121ae
...@@ -211,12 +211,12 @@ ...@@ -211,12 +211,12 @@
"navigationBarTitleText": "$emit()" "navigationBarTitleText": "$emit()"
} }
}, },
{ {
"path": "pages/component-instance/forceUpdate-function/forceUpdate-function", "path": "pages/component-instance/force-update/force-update",
"style": { "style": {
"navigationBarTitleText": "$forceUpdate()" "navigationBarTitleText": "$forceUpdate"
} }
}, },
{ {
"path": "pages/component-instance/nextTick-function/nextTick-function", "path": "pages/component-instance/nextTick-function/nextTick-function",
"style": { "style": {
...@@ -321,12 +321,6 @@ ...@@ -321,12 +321,6 @@
"navigationBarTitleText": "render function" "navigationBarTitleText": "render function"
} }
}, },
{
"path": "pages/rendering/force-update/force-update",
"style": {
"navigationBarTitleText": "$forceUpdate"
}
},
{ {
"path": "pages/composition/mixins/mixins", "path": "pages/composition/mixins/mixins",
"style": { "style": {
......
const PAGE_PATH = '/pages/rendering/force-update/force-update' const PAGE_PATH = '/pages/component-instance/force-update/force-update'
describe('$forceUpdate', () => { describe('$forceUpdate', () => {
if (process.env.uniTestPlatformInfo.startsWith('android')) { if (process.env.uniTestPlatformInfo.startsWith('android')) {
...@@ -9,12 +9,12 @@ describe('$forceUpdate', () => { ...@@ -9,12 +9,12 @@ describe('$forceUpdate', () => {
}) })
it('basic', async () => { it('basic', async () => {
const timeEl = await page.$('.time') const timeEl = await page.$('.time')
const timeText1 = await timeEl.text() const timeText1 = (await timeEl.text()).replace('Date.now(): ', '')
const triggerForceUpdateBtn = await page.$('.trigger-force-update-btn') const triggerForceUpdateBtn = await page.$('.trigger-force-update-btn')
await triggerForceUpdateBtn.tap() await triggerForceUpdateBtn.tap()
const timeText2 = await timeEl.text() const timeText2 = (await timeEl.text()).replace('Date.now(): ', '')
expect(parseInt(timeText2)).toBeGreaterThan(parseInt(timeText1)) expect(parseInt(timeText2)).toBeGreaterThan(parseInt(timeText1))
}) })
} else { } else {
......
<template> <template>
<view class="page"> <view class="page">
<view class="split-title">$forceUpdate</view> <view class="split-title">$forceUpdate</view>
<text class="uni-common-mt time">{{ Date.now() }}</text> <text class="uni-common-mt time">Date.now(): {{ Date.now() }}</text>
<button <button
class="uni-common-mt trigger-force-update-btn" class="uni-common-mt trigger-force-update-btn"
type="primary" type="primary"
......
<template>
<view class="page">
<view class="row">
<text>不支持 $forceUpdate()</text>
</view>
</view>
</template>
<script>
type Obj = {
key: string
}
export default {
data () {
return {
// obj: {} as Obj
}
},
mounted () {
// this.obj.key = 'value'
// console.log(this.$forceUpdate)
}
}
</script>
<style>
.row {
display: flex;
flex-direction: row;
justify-content: space-between;
margin-bottom: 10px;
}
</style>
...@@ -258,17 +258,7 @@ ...@@ -258,17 +258,7 @@
name: 'unrecognized component', name: 'unrecognized component',
url: 'unrecognized-component', url: 'unrecognized-component',
enable: true, enable: true,
}, },
{
name: '$forceUpdate',
url: 'force-update',
// #ifdef APP-ANDROID
enable: true,
// #endif
// #ifndef APP-ANDROID
enable: false,
// #endif
},
] as PageItem[], ] as PageItem[],
}, },
{ {
...@@ -336,10 +326,15 @@ ...@@ -336,10 +326,15 @@
url: 'emit-function', url: 'emit-function',
enable: true, enable: true,
}, },
{ {
name: '$forceUpdate', name: '$forceUpdate',
url: 'forceUpdate-function', url: 'force-update',
enable: false, // #ifdef APP-ANDROID
enable: true,
// #endif
// #ifndef APP-ANDROID
enable: false,
// #endif
}, },
{ {
name: '$nextTick', name: '$nextTick',
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册