vue的类element的input类型组件封装
前提:题主之前只是随意的封装,项目统一ui,然后只实现了父组件拿子组件值,没有实现父组件修改子组件的值,仔细看了文档才知道用model的作用,直接上代码
Vue.component("base-input", {
model: {
prop: "val",
event: "input"
},
props: {
val: [String, Number]
},
template: `
<input
type="text"
v-bind:value="val"
@input="$emit('input', $event.target.value)"
>
`
});
父组件使用
<base-input v-model=""></base-input>
原因系解:等作者补坑

浙公网安备 33010602011771号