diff --git a/pages/directive/v-model/Foo-composition.uvue b/pages/directive/v-model/Foo-composition.uvue
index 4edee63267bf693d61addaa5b3af0e65a9ffd177..f85b495429d9531d0c330f471876e1cb6c8dbe47 100644
--- a/pages/directive/v-model/Foo-composition.uvue
+++ b/pages/directive/v-model/Foo-composition.uvue
@@ -8,11 +8,18 @@
v-model:msg in Foo:
{{ msg }}
-
defineModel num:
{{ num }}
+
+ defineModel strArr:
+ {{ JSON.stringify(strArr) }}
+
+
+ defineModel numArr:
+ {{ JSON.stringify(numArr) }}
+
@@ -28,9 +35,14 @@ const msg = defineModel('msg', { type: String, default: 'default msg' })
const num = defineModel('num', { type: Number, default: 1 })
+const strArr = defineModel('strArr', { default: () => [] as string[] })
+const numArr = defineModel('numArr', {type: Array as PropType, required: true })
+
const updateValue = () => {
modelValue.value += '1'
msg.value += '2'
num.value++
+ strArr.value.push(`${strArr.value.length}`)
+ numArr.value.push(numArr.value.length)
}
diff --git a/pages/directive/v-model/v-model-composition.test.js b/pages/directive/v-model/v-model-composition.test.js
index 1f752e4e82e22f1ed4eda6ff6193332cc7f47db0..2d4750d63a2cb3b4b5a1b8ec3c5296f5cb9555aa 100644
--- a/pages/directive/v-model/v-model-composition.test.js
+++ b/pages/directive/v-model/v-model-composition.test.js
@@ -19,10 +19,15 @@ describe('defineModel', () => {
const modelMsgInput = await page.$('#model-msg-input')
expect(await modelMsgInput.value()).toBe('msg')
- const modelNumText = await page.$('#model-num-text')
- expect(await modelNumText.text()).toBe('1')
-
-
+ const modelNumText = await page.$('#model-num-text')
+ expect(await modelNumText.text()).toBe('1')
+
+ const modelStrArrText = await page.$('#model-str-arr-text')
+ expect(await modelStrArrText.text()).toBe('["0"]')
+
+ const modelNumArrText = await page.$('#model-num-arr-text')
+ expect(await modelNumArrText.text()).toBe('[0]')
+
const updateValueBtn = await page.$('#update-value-btn')
await updateValueBtn.tap()
@@ -32,7 +37,10 @@ describe('defineModel', () => {
expect(await modelValueInput.value()).toBe('str1')
expect(await modelMsgText.text()).toBe('msg2')
- expect(await modelMsgInput.value()).toBe('msg2')
+ expect(await modelMsgInput.value()).toBe('msg2')
+
+ expect(await modelStrArrText.text()).toBe('["0","1"]')
+ expect(await modelNumArrText.text()).toBe('[0,1]')
const handleModelValueUpdateRes = await page.$('#handle-model-value-update-res')
expect(await handleModelValueUpdateRes.text()).toBe('str1')
diff --git a/pages/directive/v-model/v-model-composition.uvue b/pages/directive/v-model/v-model-composition.uvue
index 43465fbe4c016ab640605b7f2123ab83bbaaca42..dbe094f3ca2b234735ca1da684e0dd7adc9100c5 100644
--- a/pages/directive/v-model/v-model-composition.uvue
+++ b/pages/directive/v-model/v-model-composition.uvue
@@ -3,8 +3,11 @@
+ @update:msg="handleModelMsgUpdate"
+ />
@@ -23,6 +26,8 @@ import Foo from './Foo-composition.uvue'
const str = ref('str')
const msg = ref('msg')
+const strArr = ref(['0'])
+const numArr = ref([0])
const handleModelValueUpdateRes = ref('')
const handleModelValueUpdate = (val : string) => {