diff --git a/pages.json b/pages.json index ebcc3de5f8db594a6d370e960f9b3921a894899b..0630464aa6578ec4b8dfbc06df11adab5617ec66 100644 --- a/pages.json +++ b/pages.json @@ -147,6 +147,19 @@ "navigationBarTitleText": "v-html 组合式 API" } }, + { + "path": "pages/directive/v-show/v-show-options", + "style": { + "navigationBarTitleText": "v-show 选项式 API" + } + }, + { + "path": "pages/directive/v-show/v-show-composition", + "style": { + "navigationBarTitleText": "v-show 组合式 API" + } + }, + { "path": "pages/directive/v-bind/v-bind", "style": { @@ -271,12 +284,6 @@ "navigationBarTitleText": "v-pre" } }, - { - "path": "pages/directive/v-show/v-show", - "style": { - "navigationBarTitleText": "v-show" - } - }, { "path": "pages/directive/v-slot/v-slot", "style": { diff --git a/pages/directive/v-show/v-show-composition.uvue b/pages/directive/v-show/v-show-composition.uvue new file mode 100644 index 0000000000000000000000000000000000000000..99bba15f227a7aaf3ea55cf13e4f44c040db5889 --- /dev/null +++ b/pages/directive/v-show/v-show-composition.uvue @@ -0,0 +1,26 @@ + + + diff --git a/pages/directive/v-show/v-show-options.uvue b/pages/directive/v-show/v-show-options.uvue new file mode 100644 index 0000000000000000000000000000000000000000..75a5ef01e293d6223bc2c7aca6d2516236903ff2 --- /dev/null +++ b/pages/directive/v-show/v-show-options.uvue @@ -0,0 +1,29 @@ + + + diff --git a/pages/directive/v-show/v-show.test.js b/pages/directive/v-show/v-show.test.js index a7ff668ea6fa4aef9757445cafe0340484e60548..19b1aaa84b47b5bdc2f74092a7220df6b96ef23f 100644 --- a/pages/directive/v-show/v-show.test.js +++ b/pages/directive/v-show/v-show.test.js @@ -1,36 +1,41 @@ -const PAGE_PATH = '/pages/directive/v-show/v-show' +const OPTIONS_PAGE_PATH = '/pages/directive/v-show/v-show-options' +const COMPOSITION_PAGE_PATH = '/pages/directive/v-show/v-show-composition' describe('v-show', () => { let page - beforeAll(async () => { - page = await program.reLaunch(PAGE_PATH) - await page.waitFor(500) - }) - it('style::display', async () => { - const element = await page.$('.v-show-content') - expect(await element.style('display')).toBe('flex') + + const test = async (page) => { + let dataInfo = await page.data('dataInfo') + expect(dataInfo.show).toBe(true) + + const vShowElement = await page.$('.v-show-element') + expect(await vShowElement.style('display')).toBe('flex') + - const toggle = await page.$('.btn-toggle') + const toggle = await page.$('#toggle-btn') await toggle.tap() - expect(await element.style('display')).toBe('none') + + dataInfo = await page.data('dataInfo') + expect(dataInfo.show).toBe(false) + expect(await vShowElement.style('display')).toBe('none') + await toggle.tap() - expect(await element.style('display')).toBe('flex') + dataInfo = await page.data('dataInfo') + expect(dataInfo.show).toBe(true) + expect(await vShowElement.style('display')).toBe('flex') + } + + it('v-show options API', async () => { + page = await program.reLaunch(OPTIONS_PAGE_PATH) + await page.waitFor('view') + + await test(page) + }) + + it('v-show composition API', async () => { + page = await program.reLaunch(COMPOSITION_PAGE_PATH) + await page.waitFor('view') + + await test(page) }) - // it('screenshot', async () => { - // const toggle = await page.$('.btn-toggle') - // const element = await page.$('.hello') - - // const image1 = await program.screenshot() - // expect(image1).toMatchSnapshot() - - // await toggle.tap() - // await page.waitFor(20) - // const image2 = await program.screenshot() - // expect(image2).toMatchSnapshot() - - // await toggle.tap() - // await page.waitFor(20) - // const image3 = await program.screenshot() - // expect(image3).toMatchSnapshot() - // }) }) \ No newline at end of file diff --git a/pages/directive/v-show/v-show.uvue b/pages/directive/v-show/v-show.uvue deleted file mode 100644 index 9f6305f612171fd2127d825066180b3e1bdfd819..0000000000000000000000000000000000000000 --- a/pages/directive/v-show/v-show.uvue +++ /dev/null @@ -1,33 +0,0 @@ - - - - - \ No newline at end of file diff --git a/pages/index/index.uvue b/pages/index/index.uvue index 3c771d8ab062f0466272e9e38c05da136568ded3..1008be7bd52675876bbb445fc145873ca929b8da 100644 --- a/pages/index/index.uvue +++ b/pages/index/index.uvue @@ -650,6 +650,22 @@ export default { url: 'v-html-composition' }, ] + }, + { + id: 'v-show', + name: 'v-show', + children: [ + { + id: 'v-show-options', + name: 'v-show 选项式 API', + url: 'v-show-options' + }, + { + id: 'v-show-composition', + name: 'v-show 组合式 API', + url: 'v-show-composition' + }, + ] } ] }, diff --git a/refactor_options-API-composition-API-correspondence.md b/refactor_options-API-composition-API-correspondence.md index 3d449780a171c4f54436c9ca45d065173116c0ce..5fcdccc70974c60783b5f24a9c2176af01f6d048 100644 --- a/refactor_options-API-composition-API-correspondence.md +++ b/refactor_options-API-composition-API-correspondence.md @@ -154,7 +154,7 @@ function transform(fileInfo, api) { ## directives - [x] v-html -- [ ] v-show +- [x] v-show - [ ] v-if v-else-if v-else - [ ] v-for - [ ] v-on