diff --git a/pages.json b/pages.json index d81862ac9751abdf5b776929cd22f50a671394d4..128c081fee9253b249abe39cd243c47251a96cb9 100644 --- a/pages.json +++ b/pages.json @@ -201,6 +201,20 @@ "navigationBarTitleText": "v-pre" } }, + // #ifdef APP + { + "path": "pages/directive/v-once/v-once-options", + "style": { + "navigationBarTitleText": "v-once 选项式 API" + } + }, + { + "path": "pages/directive/v-once/v-once-composition", + "style": { + "navigationBarTitleText": "v-once 组合式 API" + } + }, + // #endif { @@ -265,14 +279,6 @@ "navigationBarTitleText": "v-model" } }, - // #ifdef APP - { - "path": "pages/directive/v-once/v-once", - "style": { - "navigationBarTitleText": "v-once" - } - }, - // #endif { "path": "pages/directive/v-memo/v-memo", "style": { diff --git a/pages/directive/v-once/v-once-composition.uvue b/pages/directive/v-once/v-once-composition.uvue new file mode 100644 index 0000000000000000000000000000000000000000..5354f61e25a1bcd81cbfcad81a1fda74e3840a7a --- /dev/null +++ b/pages/directive/v-once/v-once-composition.uvue @@ -0,0 +1,22 @@ + + + diff --git a/pages/directive/v-once/v-once-options.uvue b/pages/directive/v-once/v-once-options.uvue new file mode 100644 index 0000000000000000000000000000000000000000..116238b412229333c404ea0214d9ef065418cabf --- /dev/null +++ b/pages/directive/v-once/v-once-options.uvue @@ -0,0 +1,30 @@ + + + diff --git a/pages/directive/v-once/v-once.test.js b/pages/directive/v-once/v-once.test.js index eeb285664b7d9c3dfb8de44ac42ab8f0b00f431d..cc4046efc1619ddfa5b92ed2b5a67883983ae632 100644 --- a/pages/directive/v-once/v-once.test.js +++ b/pages/directive/v-once/v-once.test.js @@ -1,4 +1,5 @@ -const PAGE_PATH = '/pages/directive/v-once/v-once' +const OPTIONS_PAGE_PATH = '/pages/directive/v-once/v-once-options' +const COMPOSITION_PAGE_PATH = '/pages/directive/v-once/v-once-composition' describe('v-once', () => { if (process.env.uniTestPlatformInfo.startsWith('web')) { @@ -9,22 +10,29 @@ describe('v-once', () => { 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 vOnceTextEl = await page.$('.v-once-text') - let vOnceTextText = await vOnceTextEl.text() - expect(vOnceTextText).toBe('This will never change: hello world') + + const vOnceMsg = await page.$('#v-once-msg') + expect(await vOnceMsg.text()).toBe('hello world') + + const msg = await page.$('#msg') + expect(await msg.text()).toBe('hello world') - const btn = await page.$('.btn') + const btn = await page.$('#btn') await btn.tap() - const msg = await page.data('msg') - expect(msg).toBe('msg changed') - - vOnceTextText = await vOnceTextEl.text() - expect(vOnceTextText).toBe('This will never change: hello world') + expect(await vOnceMsg.text()).toBe('hello world') + expect(await msg.text()).toBe('msg changed') + } + + it('v-once options API', async () => { + await test(OPTIONS_PAGE_PATH) + }) + + it('v-once composition API', async () => { + await test(COMPOSITION_PAGE_PATH) }) }) \ No newline at end of file diff --git a/pages/directive/v-once/v-once.uvue b/pages/directive/v-once/v-once.uvue deleted file mode 100644 index e74da3490a457e54538fcfd0a3f5c47815ad2feb..0000000000000000000000000000000000000000 --- a/pages/directive/v-once/v-once.uvue +++ /dev/null @@ -1,23 +0,0 @@ - - - diff --git a/pages/index/index.uvue b/pages/index/index.uvue index 8438288a0dbb4ff4fd7a27f974ab3b3462a70a58..2ce8244d30a0ddf4b1ec7ff0d251669cdbc9e41a 100644 --- a/pages/index/index.uvue +++ b/pages/index/index.uvue @@ -719,7 +719,25 @@ export default { id: 'v-pre', name: 'v-pre', url: 'v-pre/v-pre' - } + }, + // #ifdef APP + { + id: 'v-once', + name: 'v-once', + children: [ + { + id: 'v-once-options', + name: 'v-once 选项式 API', + url: 'v-once-options' + }, + { + id: 'v-once-composition', + name: 'v-once 组合式 API', + url: 'v-once-composition' + }, + ] + }, + // #endif ] }, { diff --git a/refactor_options-API-composition-API-correspondence.md b/refactor_options-API-composition-API-correspondence.md index 968b72e5380c11c6f09f2f39d7de693653e31f2c..2069d6545f73325f3a143e53dc0962da44a694f8 100644 --- a/refactor_options-API-composition-API-correspondence.md +++ b/refactor_options-API-composition-API-correspondence.md @@ -161,11 +161,11 @@ function transform(fileInfo, api) { - [ ] v-bind - [ ] v-model - [ ] v-slot -- [ ] v-pre -- [ ] v-once +- [x] v-pre +- [x] v-once - [ ] v-memo - [ ] v-text -- [ ] -cloak +- [ ] v-cloak 暂不支持 ## lifecycle