From 84fcdd8be8643a6ffb8c76b26767dd7f35805e67 Mon Sep 17 00:00:00 2001 From: zhenyuWang <13641039885@163.com> Date: Tue, 14 May 2024 19:18:35 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E4=BC=98=E5=8C=96=E7=A4=BA?= =?UTF-8?q?=E4=BE=8B=E5=8F=8A=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../template/template-composition.uvue | 8 ++++---- .../template/template-options.uvue | 6 +++--- .../special-elements/template/template.test.js | 9 ++++----- .../shallow-reactive/shallow-reactive.test.js | 4 ++-- .../shallow-reactive/shallow-reactive.uvue | 16 +++++++++------- .../shallow-readonly/shallow-readonly.uvue | 9 +++++---- .../advanced/shallow-ref/shallow-ref.test.js | 4 ++-- .../advanced/shallow-ref/shallow-ref.uvue | 13 +++++++------ pages/reactivity/core/reactive/reactive.test.js | 2 +- pages/reactivity/core/reactive/reactive.uvue | 2 +- pages/reactivity/core/readonly/readonly.uvue | 10 +++++----- pages/reactivity/core/ref/ref.test.js | 2 +- pages/reactivity/core/ref/ref.uvue | 8 ++++---- 13 files changed, 48 insertions(+), 45 deletions(-) diff --git a/pages/built-in/special-elements/template/template-composition.uvue b/pages/built-in/special-elements/template/template-composition.uvue index 6c2ac64..4958685 100644 --- a/pages/built-in/special-elements/template/template-composition.uvue +++ b/pages/built-in/special-elements/template/template-composition.uvue @@ -1,9 +1,9 @@ diff --git a/pages/reactivity/core/readonly/readonly.uvue b/pages/reactivity/core/readonly/readonly.uvue index 0bab5bd..a7f3e98 100644 --- a/pages/reactivity/core/readonly/readonly.uvue +++ b/pages/reactivity/core/readonly/readonly.uvue @@ -40,14 +40,14 @@ type Data = { num : number, arr : string[] } - -const data = reactive({ +// 可通过泛型指定类型 +const data = reactive({ str: 'default str', num: 0, arr: ['a', 'b', 'c'] -} as Data) - -const readonlyData = readonly(data) +}) +// 可通过泛型指定类型 +const readonlyData = readonly(data) const updateData = () => { data.str = 'new str' diff --git a/pages/reactivity/core/ref/ref.test.js b/pages/reactivity/core/ref/ref.test.js index a759a9c..8f3831f 100644 --- a/pages/reactivity/core/ref/ref.test.js +++ b/pages/reactivity/core/ref/ref.test.js @@ -14,7 +14,7 @@ describe('ref', () => { const counterCount = await page.$('#counter-count') expect(await counterCount.text()).toBe('counter.count: 0') - const incrementBtn = await page.$('.increment-btn') + const incrementBtn = await page.$('#increment-btn') await incrementBtn.tap() expect(await count1.text()).toBe('count1: 2') diff --git a/pages/reactivity/core/ref/ref.uvue b/pages/reactivity/core/ref/ref.uvue index ce1c556..93cc9f6 100644 --- a/pages/reactivity/core/ref/ref.uvue +++ b/pages/reactivity/core/ref/ref.uvue @@ -3,7 +3,7 @@ count1: {{ count1 }} count2: {{ count2 }} counter.count: {{ counter.count }} - + @@ -15,10 +15,10 @@ type Counter = { count : number } - // TODO: Android 端暂不支持通过泛型指定类型,可通过 as 方式指定类型 - const counter = ref({ + // 可通过泛型指定类型 + const counter = ref({ count: 0 - } as Counter) + }) const increment = () => { count1.value++ -- GitLab