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

feat: v-memo

上级 5ebf47f2
......@@ -96,6 +96,12 @@
"navigationBarTitleText": "v-once"
}
},
{
"path": "pages/directive/v-memo/v-memo",
"style": {
"navigationBarTitleText": "v-memo"
}
},
{
"path": "pages/directive/v-show/v-show",
"style": {
......
const PAGE_PATH = '/pages/directive/v-memo/v-memo'
describe('v-memo', () => {
if (process.env.uniTestPlatformInfo.startsWith('android')) {
let page
beforeAll(async () => {
page = await program.reLaunch(PAGE_PATH)
await page.waitFor('view')
})
it('basic', async () => {
const equivalentVOnceTextEl = await page.$('.equivalent-v-once-text')
let equivalentVOnceTextText = await equivalentVOnceTextEl.text()
expect(equivalentVOnceTextText).toBe(
'This will never change: hello world'
)
const vMemoTextEl = await page.$('.v-memo-text')
let vMemoTextText = await vMemoTextEl.text()
expect(vMemoTextText).toBe(
'This will change when num change, msg: hello world, num: 0'
)
const changeMessageBtn = await page.$('.change-message-btn')
await changeMessageBtn.tap()
const msg = await page.data('msg')
expect(msg).toBe('msg changed')
equivalentVOnceTextText = await equivalentVOnceTextEl.text()
expect(equivalentVOnceTextText).toBe(
'This will never change: hello world'
)
vMemoTextText = await vMemoTextEl.text()
expect(vMemoTextText).toBe(
'This will change when num change, msg: hello world, num: 0'
)
const plusNumBtn = await page.$('.plus-num-btn')
await plusNumBtn.tap()
vMemoTextText = await vMemoTextEl.text()
expect(vMemoTextText).toBe(
'This will change when num change, msg: msg changed, num: 1'
)
})
} else {
// TODO: web 端暂不支持
it('web', async () => {
expect(1).toBe(1)
})
}
})
<template>
<view class="page">
<view class="split-title">v-memo</view>
<text class="uni-common-mt equivalent-v-once-text" v-memo="[]"
>This will never change: {{ msg }}</text
>
<text class="uni-common-mt v-memo-text" v-memo="[num]"
>This will change when num change, msg: {{ msg }}, num: {{ num }}</text
>
<text class="uni-common-mt">msg: {{ msg }}</text>
<text class="uni-common-mt">num: {{ num }}</text>
<button class="uni-common-mt change-message-btn" type="primary" @click="changeMessage">
change message
</button>
<button class="uni-common-mt plus-num-btn" type="primary" @click="plusNum">
plus num
</button>
</view>
</template>
<script lang="uts">
export default {
data() {
return {
msg: 'hello world',
num: 0
}
},
methods: {
changeMessage() {
this.msg = 'msg changed'
},
plusNum(){
this.num++
}
}
}
</script>
......@@ -173,12 +173,22 @@
{
name: 'v-once',
url: 'v-once',
// #ifdef APP-ANDROID
enable: true,
// #endif
// #ifndef APP-ANDROID
enable: false,
// #endif
},
{
name: 'v-memo',
url: 'v-memo',
// #ifdef APP-ANDROID
enable: true,
// #endif
// #ifndef APP-ANDROID
enable: false,
// #endif
},
{
name: 'v-cloak',
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册