diff --git a/pages/composition-api/basic/define-model/Foo.uvue b/pages/composition-api/basic/define-model/Foo.uvue index d41a937cda23e3eb0bc705f3d45061d96e6a56e6..3576249b42a2776cfc0c6f942b9310bfc0fdd792 100644 --- a/pages/composition-api/basic/define-model/Foo.uvue +++ b/pages/composition-api/basic/define-model/Foo.uvue @@ -2,6 +2,7 @@ modelValue in Foo: {{modelValue}} msg in Foo: {{msg}} + num: {{defaultNum}} @@ -11,7 +12,8 @@ const modelValue = defineModel({ type: String }) // 在被修改时,触发 "update:msg" 事件 - const msg = defineModel('msg', { type: String }) + const msg = defineModel('msg', { type: String, default: 'default msg' }) + const defaultNum = defineModel('num', { type: Number, default: 10 }) const updateValue = () => { modelValue.value += '1' diff --git a/pages/composition-api/basic/define-model/define-model.test.js b/pages/composition-api/basic/define-model/define-model.test.js index 58607dd57706d9c52a04de4fd78093ca6a4d05dd..95c203551812ec6b05a4545ffdba3114598b0db8 100644 --- a/pages/composition-api/basic/define-model/define-model.test.js +++ b/pages/composition-api/basic/define-model/define-model.test.js @@ -20,8 +20,11 @@ describe('defineModel', () => { const modelValueInput = await page.$('#model-value-input') expect(await modelValueInput.property('value')).toBe('str') - const msgText = await page.$('#msg-text') - expect(await msgText.text()).toBe('msg in Foo: msg') + const msgText = await page.$('#msg-text') + expect(await msgText.text()).toBe('msg in Foo: msg') + + const defaultNumText = await page.$('#default-num-text') + expect(await defaultNumText.text()).toBe('num: 10') const msgInput = await page.$('#msg-input') expect(await msgInput.property('value')).toBe('msg')