diff --git a/pages/built-in/special-elements/template/template-composition.uvue b/pages/built-in/special-elements/template/template-composition.uvue
index 6c2ac6475e027562e98af093f2d59ffe182937b8..49586853c09890e863bb6de71ebec30e1c22c400 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 @@
- {{ title }}
+ {{ title }}
- {{ dataInfo.isShow ? '点击隐藏' : '点击显示' }}
+
{{ index + 1 }}.{{ item.name }}
@@ -31,14 +31,14 @@ const list = ref([
{
name: 'foo2'
}
-] as ListItem[])
+])
const handleShow = () => {
dataInfo.isShow = !dataInfo.isShow
}
const goMapStyle = () => {
- uni.navigateTo({ url: '/pages/built-in/component/template/template-map-style-composition' })
+ uni.navigateTo({ url: '/pages/built-in/special-elements/template/template-map-style-composition' })
}
defineExpose({
diff --git a/pages/built-in/special-elements/template/template-options.uvue b/pages/built-in/special-elements/template/template-options.uvue
index 5dfffc298e6a33605c27e12a570091d0d17cf076..0d1b14ee3949a8275bc879c18849425d62d1198d 100644
--- a/pages/built-in/special-elements/template/template-options.uvue
+++ b/pages/built-in/special-elements/template/template-options.uvue
@@ -1,9 +1,9 @@
- {{ title }}
+ {{ title }}
- {{ dataInfo.isShow ? '点击隐藏' : '点击显示' }}
+
{{ index + 1 }}.{{ item.name }}
@@ -39,7 +39,7 @@ export default {
this.dataInfo.isShow = !this.dataInfo.isShow
},
goMapStyle() {
- uni.navigateTo({ url: '/pages/built-in/component/template/template-map-style-options' })
+ uni.navigateTo({ url: '/pages/built-in/special-elements/template/template-map-style-options' })
}
}
}
diff --git a/pages/built-in/special-elements/template/template.test.js b/pages/built-in/special-elements/template/template.test.js
index 95c8eef9a7ebeba75a685f74b231296d093643a5..04f3f60da9a824f7d7d0d1e6785fc1b2c0f3f7ae 100644
--- a/pages/built-in/special-elements/template/template.test.js
+++ b/pages/built-in/special-elements/template/template.test.js
@@ -5,16 +5,15 @@ describe('built-in/special-elements/component', () => {
let page
const test = async () => {
await page.waitFor('view')
- expect.assertions(4);
- const showBtn = await page.$('.show-botton')
+ const showBtn = await page.$('#show-botton')
+ expect(await showBtn.text()).toBe("点击显示")
await showBtn.tap()
const dataInfo = await page.data('dataInfo')
expect(dataInfo.isShow).toBeTruthy()
- const getTitle = await page.$('.title')
+ const getTitle = await page.$('#title')
expect(await getTitle.text()).toBe("hello")
- const getShow = await page.$('.show-botton')
- expect(await getShow.text()).toBe("点击隐藏")
+ expect(await showBtn.text()).toBe("点击隐藏")
expect((await page.$$('.item')).length).toBe(2)
}
it('template Options API', async () => {
diff --git a/pages/reactivity/advanced/shallow-reactive/shallow-reactive.test.js b/pages/reactivity/advanced/shallow-reactive/shallow-reactive.test.js
index af5b04b066bc3fba51a18a83f4105616c1fd2bfa..1f755177a9858fee74eaea27faa70eafa7df57c6 100644
--- a/pages/reactivity/advanced/shallow-reactive/shallow-reactive.test.js
+++ b/pages/reactivity/advanced/shallow-reactive/shallow-reactive.test.js
@@ -15,12 +15,12 @@ describe('shallowReactive', () => {
const stateNestedCount = await page.$('#state-nested-count')
expect(await stateNestedCount.text()).toBe('0')
- const incrementStateNestedCountBtn = await page.$('.increment-state-nested-count-btn')
+ const incrementStateNestedCountBtn = await page.$('#increment-state-nested-count-btn')
await incrementStateNestedCountBtn.tap()
expect(await stateNestedCount.text()).toBe('0')
- const incrementStateCountBtn = await page.$('.increment-state-count-btn')
+ const incrementStateCountBtn = await page.$('#increment-state-count-btn')
await incrementStateCountBtn.tap()
if (isWeb) {
diff --git a/pages/reactivity/advanced/shallow-reactive/shallow-reactive.uvue b/pages/reactivity/advanced/shallow-reactive/shallow-reactive.uvue
index 83bb53af1f116834102620a95b64b0092f4eec7d..dbfa009681229eb8f1b222855d804b15d7db8c48 100644
--- a/pages/reactivity/advanced/shallow-reactive/shallow-reactive.uvue
+++ b/pages/reactivity/advanced/shallow-reactive/shallow-reactive.uvue
@@ -8,13 +8,14 @@
state.nested.count:
{{ state.nested.count }}
-
@@ -28,13 +29,14 @@ type StateNested = {
type State = {
count : number,
nested : StateNested
-}
-const state = shallowReactive({
+}
+// 可通过泛型指定类型
+const state = shallowReactive({
count: 0,
nested: {
count: 0
- } as StateNested
-} as State)
+ }
+})
const incrementStateCount = () => {
state.count++
diff --git a/pages/reactivity/advanced/shallow-readonly/shallow-readonly.uvue b/pages/reactivity/advanced/shallow-readonly/shallow-readonly.uvue
index 9f4b6d4fe1820db31c8d13ef05c752d32280d938..80857c195cd2f6fdfd93ca4ae5e007325470fb9d 100644
--- a/pages/reactivity/advanced/shallow-readonly/shallow-readonly.uvue
+++ b/pages/reactivity/advanced/shallow-readonly/shallow-readonly.uvue
@@ -35,13 +35,14 @@ type StateNested = {
type State = {
count : number,
nested : StateNested
-}
-const state = shallowReadonly({
+}
+// 可通过泛型指定类型
+const state = shallowReadonly({
count: 0,
nested: {
count: 0
- } as StateNested
-} as State)
+ }
+})
// #ifdef APP
const incrementStateCount = () => {
diff --git a/pages/reactivity/advanced/shallow-ref/shallow-ref.test.js b/pages/reactivity/advanced/shallow-ref/shallow-ref.test.js
index 4231a50f004fe9347f31905f38290d051bcb6b39..859dca8e5da5095b9d7040089a0dfeafcc30ca11 100644
--- a/pages/reactivity/advanced/shallow-ref/shallow-ref.test.js
+++ b/pages/reactivity/advanced/shallow-ref/shallow-ref.test.js
@@ -10,12 +10,12 @@ describe('shallowRef', () => {
const stateCount = await page.$('#state-count')
expect(await stateCount.text()).toBe('0')
- const incrementStateCountBtn = await page.$('.increment-state-count-btn')
+ const incrementStateCountBtn = await page.$('#increment-state-count-btn')
await incrementStateCountBtn.tap()
expect(await stateCount.text()).toBe('0')
- const updateStateBtn = await page.$('.update-state-btn')
+ const updateStateBtn = await page.$('#update-state-btn')
await updateStateBtn.tap()
expect(await stateCount.text()).toBe('1')
diff --git a/pages/reactivity/advanced/shallow-ref/shallow-ref.uvue b/pages/reactivity/advanced/shallow-ref/shallow-ref.uvue
index 4fa8f80067ad1d549a7a6a7b9a139c74148fca15..69afe90f9467a9beb5eb2fc94f6c7a13ac3eae9e 100644
--- a/pages/reactivity/advanced/shallow-ref/shallow-ref.uvue
+++ b/pages/reactivity/advanced/shallow-ref/shallow-ref.uvue
@@ -4,12 +4,13 @@
state.count:
{{ state.count }}
-
-
+
@@ -17,10 +18,10 @@
type State = {
count: number
}
-
-const state = shallowRef({
+// 可通过泛型指定类型
+const state = shallowRef({
count: 0
-} as State)
+})
const incrementStateCount = () => {
state.value.count++
diff --git a/pages/reactivity/core/reactive/reactive.test.js b/pages/reactivity/core/reactive/reactive.test.js
index 4d3ccc03c7e9927d91b73040f6b2ebbf1220f4ba..df73bba7c5e32ee01816a97696410f51a2411f0d 100644
--- a/pages/reactivity/core/reactive/reactive.test.js
+++ b/pages/reactivity/core/reactive/reactive.test.js
@@ -19,7 +19,7 @@ describe('reactive', () => {
const objArr = await page.$('#obj-arr')
expect(await objArr.text()).toBe('["a","b","c"]')
- const updateBtn = await page.$('.update-btn')
+ const updateBtn = await page.$('#update-btn')
await updateBtn.tap()
expect(await count.text()).toBe('2')
diff --git a/pages/reactivity/core/reactive/reactive.uvue b/pages/reactivity/core/reactive/reactive.uvue
index 1827c9378bca6ceaff066193def2de2496bd6fb0..ae813e43c4a60634eb36c8d7c08e45b441377523 100644
--- a/pages/reactivity/core/reactive/reactive.uvue
+++ b/pages/reactivity/core/reactive/reactive.uvue
@@ -16,7 +16,7 @@
obj.arr:
{{ JSON.stringify(obj['arr']) }}
-
+
diff --git a/pages/reactivity/core/readonly/readonly.uvue b/pages/reactivity/core/readonly/readonly.uvue
index 0bab5bd6b660e37d3ce0654a5a8690f4d5cc6828..a7f3e981ba04155e335d84a2f3bd9f0c01b9bd37 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 a759a9c5d12e2482fdcaa303e997617301dc3e19..8f3831ff8c5395fd8446614f3616fd208b619e50 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 ce1c5567c4c2bd2dc2a29216a2e5e77510886377..93cc9f60351db0545ab3d79cab5788998a7b1a7c 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++