diff --git a/pages/reactivity/core/reactive/reactive.test.js b/pages/reactivity/core/reactive/reactive.test.js index df73bba7c5e32ee01816a97696410f51a2411f0d..34ee726056aca8cc07df27be398ac29a6b5eb715 100644 --- a/pages/reactivity/core/reactive/reactive.test.js +++ b/pages/reactivity/core/reactive/reactive.test.js @@ -19,12 +19,21 @@ describe('reactive', () => { const objArr = await page.$('#obj-arr') expect(await objArr.text()).toBe('["a","b","c"]') - const updateBtn = await page.$('#update-btn') - await updateBtn.tap() + const updateCountBtn = await page.$('#update-count-btn') + await updateCountBtn.tap() + expect(await count.text()).toBe('1') - expect(await count.text()).toBe('2') + const updateObjStrBtn = await page.$('#update-obj-str-btn') + await updateObjStrBtn.tap() expect(await objStr.text()).toBe('new str') + + const updateObjNumBtn = await page.$('#update-obj-num-btn') + await updateObjNumBtn.tap() + expect(await count.text()).toBe('2') expect(await objNum.text()).toBe('2') + + const updateObjArrBtn = await page.$('#update-obj-arr-btn') + await updateObjArrBtn.tap() expect(await objArr.text()).toBe('["a","b","c","d"]') }) }) \ No newline at end of file diff --git a/pages/reactivity/core/reactive/reactive.uvue b/pages/reactivity/core/reactive/reactive.uvue index 8f3c3c0042741db782e76af8149fcbc85ee683ae..9c63c039bce83af1a762d08934a764d0fd313e36 100644 --- a/pages/reactivity/core/reactive/reactive.uvue +++ b/pages/reactivity/core/reactive/reactive.uvue @@ -16,24 +16,36 @@ obj.arr: {{ JSON.stringify(obj['arr']) }} - + + + + + const updateObjStr = () => { + obj['str'] = 'new str'; + } + + const updateObjNum = () => { + obj['num'] = (obj['num'] as number) + 1 + } + + const updateCount = () => { + count.value++ + } + + const updateObjArr = () => { + (obj['arr'] as string[]).push('d') + } + \ No newline at end of file diff --git a/pages/reactivity/core/ref/ref.test.js b/pages/reactivity/core/ref/ref.test.js index a39cb921c4dfb781d9ea73f0f746183a81b8bd79..4d6103fed5a5f8c89847e2f3a91ad68afb7651bf 100644 --- a/pages/reactivity/core/ref/ref.test.js +++ b/pages/reactivity/core/ref/ref.test.js @@ -18,13 +18,24 @@ describe('ref', () => { const counterCount = await page.$('#counter-count') expect(await counterCount.text()).toBe('0') - const changeDataBtn = await page.$('#change-data-btn') - await changeDataBtn.tap() - + const changeCountBtn = await page.$('#change-count-btn') + await changeCountBtn.tap() expect(await count.text()).toBe('1') + + const changeStrBtn = await page.$('#change-str-btn') + await changeStrBtn.tap() expect(await str.text()).toBe('new str') + + const changeBoolBtn = await page.$('#change-bool-btn') + await changeBoolBtn.tap() expect(await bool.text()).toBe('true') + + const changeArrBtn = await page.$('#change-arr-btn') + await changeArrBtn.tap() expect(await arr.text()).toBe('[1,2,3,4]') + + const changeCounterBtn = await page.$('#change-counter-btn') + await changeCounterBtn.tap() expect(await counterCount.text()).toBe('1') }) diff --git a/pages/reactivity/core/ref/ref.uvue b/pages/reactivity/core/ref/ref.uvue index 998ef9b72caf897c5cc0de9b42a94ca03d937188..661f349fd4d6cac402d52880f11ba4f5ea2b9c05 100644 --- a/pages/reactivity/core/ref/ref.uvue +++ b/pages/reactivity/core/ref/ref.uvue @@ -20,31 +20,43 @@ counter.count: {{ counter.count }} - + + + + + + const changeCount = () => { + count.value++ + } + const changeStr = () => { + str.value = 'new str' + } + const changeBool = () => { + bool.value = !bool.value + } + const changeArr = () => { + arr.value.push(arr.value.length + 1) + } + const changeCounter = () => { + counter.value.count++ + } + \ No newline at end of file