Browse Source

tweak v-model type=file warning phrasing

dev
Evan You 8 years ago
parent
commit
310f5a2f5f
  1. 3
      src/platforms/web/compiler/directives/model.js
  2. 2
      test/unit/features/directives/model-file.spec.js

3
src/platforms/web/compiler/directives/model.js

@ -114,8 +114,7 @@ function genDefaultModel (
type === 'file') { type === 'file') {
warn( warn(
`<${el.tag} v-model="${value}" type="file">:\n` + `<${el.tag} v-model="${value}" type="file">:\n` +
'File inputs are read only. You should use @change instead:\n' + `File inputs are read only. Use a v-on:change listener instead.`
`<${el.tag} @change="${value} = $event.target.files" type="file">`
) )
} }
addProp(el, 'value', isNative ? `_s(${value})` : `(${value})`) addProp(el, 'value', isNative ? `_s(${value})` : `(${value})`)

2
test/unit/features/directives/model-file.spec.js

@ -8,6 +8,6 @@ describe('Directive v-model file', () => {
}, },
template: '<input v-model="file" type="file">' template: '<input v-model="file" type="file">'
}).$mount() }).$mount()
expect('use @change instead').toHaveBeenWarned() expect('Use a v-on:change listener instead').toHaveBeenWarned()
}) })
}) })

Loading…
Cancel
Save