diff --git a/pages.json b/pages.json index 0b25dc52bbe2270174a9cac2aec4a614c16d6b7f..4a52aa87eadb367f72b887d25b346930cfa47371 100644 --- a/pages.json +++ b/pages.json @@ -183,6 +183,19 @@ "navigationBarTitleText": "v-for 组合式 API" } }, + { + "path": "pages/directive/v-on/v-on-options", + "style": { + "navigationBarTitleText": "v-on 选项式 API" + } + }, + { + "path": "pages/directive/v-on/v-on-composition", + "style": { + "navigationBarTitleText": "v-on 组合式 API" + } + }, + { "path": "pages/directive/v-bind/v-bind", @@ -246,12 +259,6 @@ "navigationBarTitleText": "v-model" } }, - { - "path": "pages/directive/v-on/v-on", - "style": { - "navigationBarTitleText": "v-on" - } - }, // #ifdef APP { "path": "pages/directive/v-once/v-once", diff --git a/pages/directive/v-on/v-on-composition.uvue b/pages/directive/v-on/v-on-composition.uvue new file mode 100644 index 0000000000000000000000000000000000000000..bea027ca3f415b247a86d34fc2a427aea9d8ba71 --- /dev/null +++ b/pages/directive/v-on/v-on-composition.uvue @@ -0,0 +1,41 @@ + + + diff --git a/pages/directive/v-on/v-on-options.uvue b/pages/directive/v-on/v-on-options.uvue new file mode 100644 index 0000000000000000000000000000000000000000..0909514affa4202f97256f1d84ab59960208750e --- /dev/null +++ b/pages/directive/v-on/v-on-options.uvue @@ -0,0 +1,45 @@ + + + diff --git a/pages/directive/v-on/v-on.test.js b/pages/directive/v-on/v-on.test.js index df9755008c0e7b428cb63be579e60754fcf5c8cd..63ab7358e8815a4ba3fd88c21ffd16026b8070ae 100644 --- a/pages/directive/v-on/v-on.test.js +++ b/pages/directive/v-on/v-on.test.js @@ -1,19 +1,29 @@ -const PAGE_PATH = '/pages/directive/v-on/v-on' +const OPTIONS_PAGE_PATH = '/pages/directive/v-on/v-on-options' +const COMPOSITION_PAGE_PATH = '/pages/directive/v-on/v-on-composition' describe('v-on', () => { let page - beforeAll(async () => { - page = await program.reLaunch(PAGE_PATH) - await page.waitFor(500) - }) - it('view:click', async () => { - const expectedCount = 6 - const countText = await page.$('.count') - const clickEls = await page.$$('.view-click') - for (let i = 0; i < clickEls.length; i++) { - await clickEls[i].tap() + + const test = async (pagePath) => { + page = await program.reLaunch(pagePath) + await page.waitFor('view') + + const count = await page.$('#count') + expect(await count.text()).toBe('0') + + const btnList = await page.$$('.btn') + for (let i = 0; i < btnList.length; i++) { + await btnList[i].tap() } - expect(await countText.text()).toBe(expectedCount + '') - expect((await page.data()).count).toBe(expectedCount) + + expect(await count.text()).toBe('6') + } + + it('v-on options API', async () => { + await test(OPTIONS_PAGE_PATH) + }) + + it('v-on composition API', async () => { + await test(COMPOSITION_PAGE_PATH) }) }) \ No newline at end of file diff --git a/pages/directive/v-on/v-on.uvue b/pages/directive/v-on/v-on.uvue deleted file mode 100644 index 9132c9d657c108643b04dfd1e3577c4d3397b297..0000000000000000000000000000000000000000 --- a/pages/directive/v-on/v-on.uvue +++ /dev/null @@ -1,42 +0,0 @@ - - - - - \ No newline at end of file diff --git a/pages/index/index.uvue b/pages/index/index.uvue index c1c9225eb6171cf9409ec8d10f6e05c9a657cbce..e5734ab35fefbf9b9c8d2a9feb082b5ed27f6674 100644 --- a/pages/index/index.uvue +++ b/pages/index/index.uvue @@ -698,6 +698,22 @@ export default { url: 'v-for-composition' }, ] + }, + { + id: 'v-on', + name: 'v-on', + children: [ + { + id: 'v-on-options', + name: 'v-on 选项式 API', + url: 'v-on-options' + }, + { + id: 'v-on-composition', + name: 'v-on 组合式 API', + url: 'v-on-composition' + }, + ] } ] }, diff --git a/refactor_options-API-composition-API-correspondence.md b/refactor_options-API-composition-API-correspondence.md index 1c622f68e60470d7297f41b891a3f82e406ec13e..968b72e5380c11c6f09f2f39d7de693653e31f2c 100644 --- a/refactor_options-API-composition-API-correspondence.md +++ b/refactor_options-API-composition-API-correspondence.md @@ -157,7 +157,7 @@ function transform(fileInfo, api) { - [x] v-show - [x] v-if v-else-if v-else - [x] v-for -- [ ] v-on +- [x] v-on - [ ] v-bind - [ ] v-model - [ ] v-slot