diff --git a/pages.json b/pages.json index 128c081fee9253b249abe39cd243c47251a96cb9..ad00c773e2f4fd50e3aaa18a4f31a17a339f897e 100644 --- a/pages.json +++ b/pages.json @@ -214,6 +214,18 @@ "navigationBarTitleText": "v-once 组合式 API" } }, + { + "path": "pages/directive/v-memo/v-memo-options", + "style": { + "navigationBarTitleText": "v-memo 选项式 API" + } + }, + { + "path": "pages/directive/v-memo/v-memo-composition", + "style": { + "navigationBarTitleText": "v-memo 组合式 API" + } + }, // #endif @@ -279,12 +291,6 @@ "navigationBarTitleText": "v-model" } }, - { - "path": "pages/directive/v-memo/v-memo", - "style": { - "navigationBarTitleText": "v-memo" - } - }, { "path": "pages/directive/v-slot/v-slot", "style": { diff --git a/pages/directive/v-memo/v-memo-composition.uvue b/pages/directive/v-memo/v-memo-composition.uvue new file mode 100644 index 0000000000000000000000000000000000000000..3815199314baf00518009b655c44e8e808e8b326 --- /dev/null +++ b/pages/directive/v-memo/v-memo-composition.uvue @@ -0,0 +1,48 @@ + + + diff --git a/pages/directive/v-memo/v-memo-options.uvue b/pages/directive/v-memo/v-memo-options.uvue new file mode 100644 index 0000000000000000000000000000000000000000..822fe3e7c53656bd5d0be4d492b7dc8a1136e4ae --- /dev/null +++ b/pages/directive/v-memo/v-memo-options.uvue @@ -0,0 +1,53 @@ + + + diff --git a/pages/directive/v-memo/v-memo.test.js b/pages/directive/v-memo/v-memo.test.js index d5bec40be68133be39b7d0354fc3057c70704a0f..7305fe87b493dc9d13bf69818583937dfb17a782 100644 --- a/pages/directive/v-memo/v-memo.test.js +++ b/pages/directive/v-memo/v-memo.test.js @@ -1,4 +1,5 @@ -const PAGE_PATH = '/pages/directive/v-memo/v-memo' +const OPTIONS_PAGE_PATH = '/pages/directive/v-memo/v-memo-options' +const COMPOSITION_PAGE_PATH = '/pages/directive/v-memo/v-memo-composition' describe('v-memo', () => { if (process.env.uniTestPlatformInfo.startsWith('web')) { @@ -9,44 +10,39 @@ describe('v-memo', () => { return } let page - beforeAll(async () => { - page = await program.reLaunch(PAGE_PATH) + const test = async (pagePath) => { + page = await program.reLaunch(pagePath) 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 neverChangeMsg = await page.$('#v-memo-never-change-msg') + expect(await neverChangeMsg.text()).toBe('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 msg = await page.$('#msg') + expect(await msg.text()).toBe('hello world') + + const numChangeMsg = await page.$('#v-memo-num-change-msg') + expect(await numChangeMsg.text()).toBe('hello world') - const changeMessageBtn = await page.$('.change-message-btn') + const changeMessageBtn = await page.$('#change-message-btn') await changeMessageBtn.tap() - const msg = await page.data('msg') - expect(msg).toBe('msg changed') + expect(await neverChangeMsg.text()).toBe('hello world') + expect(await msg.text()).toBe('msg changed') + expect(await numChangeMsg.text()).toBe('hello world') - 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 incrementNumBtn = await page.$('#increment-num-btn') + await incrementNumBtn.tap() - 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' - ) - }) + expect(await neverChangeMsg.text()).toBe('hello world') + expect(await msg.text()).toBe('msg changed') + expect(await numChangeMsg.text()).toBe('msg changed') + } + + it('v-memo options API', async () => { + await test(OPTIONS_PAGE_PATH) + }) + + it('v-memo composition API', async () => { + await test(COMPOSITION_PAGE_PATH) + }) }) diff --git a/pages/directive/v-memo/v-memo.uvue b/pages/directive/v-memo/v-memo.uvue deleted file mode 100644 index 0d64de1f7ca5043c2fdc8688e86f256ca66bca23..0000000000000000000000000000000000000000 --- a/pages/directive/v-memo/v-memo.uvue +++ /dev/null @@ -1,38 +0,0 @@ - - - diff --git a/pages/index/index.uvue b/pages/index/index.uvue index 2ce8244d30a0ddf4b1ec7ff0d251669cdbc9e41a..c9b297702a5b391c0ed1f00849bf469792845b7c 100644 --- a/pages/index/index.uvue +++ b/pages/index/index.uvue @@ -553,18 +553,22 @@ export default { name: 'toRef', url: 'to-ref/to-ref' }, - // #ifdef APP { id: 'to-refs', name: 'toRefs', - url: 'to-refs/to-refs' + url: 'to-refs/to-refs', + // #ifdef WEB + enable: false + // #endif }, { id: 'to-value', name: 'toValue', - url: 'to-value/to-value' - }, + url: 'to-value/to-value', + // #ifdef WEB + enable: false // #endif + }, { id: 'un-ref', name: 'unRef', @@ -720,7 +724,6 @@ export default { name: 'v-pre', url: 'v-pre/v-pre' }, - // #ifdef APP { id: 'v-once', name: 'v-once', @@ -728,16 +731,43 @@ export default { { id: 'v-once-options', name: 'v-once 选项式 API', - url: 'v-once-options' + url: 'v-once-options', + // #ifdef WEB + enable: false + // #endif }, { id: 'v-once-composition', name: 'v-once 组合式 API', - url: 'v-once-composition' + url: 'v-once-composition', + // #ifdef WEB + enable: false + // #endif + }, + ] + }, + { + id: 'v-memo', + name: 'v-memo', + children: [ + { + id: 'v-memo-options', + name: 'v-memo 选项式 API', + url: 'v-memo-options', + // #ifdef WEB + enable: false + // #endif + }, + { + id: 'v-memo-composition', + name: 'v-memo 组合式 API', + url: 'v-memo-composition', + // #ifdef WEB + enable: false + // #endif }, ] }, - // #endif ] }, { diff --git a/refactor_options-API-composition-API-correspondence.md b/refactor_options-API-composition-API-correspondence.md index 2069d6545f73325f3a143e53dc0962da44a694f8..cdd88db85f90c5e8b8fa3fad3af92a4acdd889f8 100644 --- a/refactor_options-API-composition-API-correspondence.md +++ b/refactor_options-API-composition-API-correspondence.md @@ -163,8 +163,8 @@ function transform(fileInfo, api) { - [ ] v-slot - [x] v-pre - [x] v-once -- [ ] v-memo -- [ ] v-text +- [x] v-memo +- [ ] v-text 暂不支持 - [ ] v-cloak 暂不支持 ## lifecycle