iview 组件的封装
程序员文章站
2024-03-18 21:37:46
...
父组件
<sac-input
v-model="filterForm.name"
label="banner名称"
ref="filterFormName"
prop="banner"
></sac-input>
子组件
<template>
<FormItem :label="label==''?'':label+':'" :prop="prop" :required="isRequired">
<Input
v-model.trim="inputVal"
:placeholder="newPlaceholder"
@on-change="onChange"
:type="type"
clearable
:autosize="autosize"
:disabled="disabled"
:number="number"
></Input>
</FormItem>
</template>
<script>
export default {
name: "sac-input",
model: {
event: "change"
},
props: {
label: {
type: String,
default: ""
},
prop: {
type: String,
default: ""
},
type: {
type: String,
default: "text"
},
autosize: [Object],
value: [String, Number],
disabled: {
type: Boolean,
default: false
},
placeholder: {
type: String,
default: ""
},
number: {
type: Boolean,
default: false
},
isRequired:{
type: Boolean,
default: null
}
},
data() {
return {
inputVal: "",
newPlaceholder: ""
};
},
watch: {
value(val, oldVal) {
this.inputVal = val;
}
},
methods: {
onChange(val) {
this.$emit("change", this.inputVal);
},
reset() {
this.inputVal = "";
this.onChange();
}
},
mounted() {
this.inputVal = this.value;
this.newPlaceholder = this.placeholder
? this.placeholder
: "请输入" + this.label;
}
};
</script>
转载于:https://my.oschina.net/u/4004801/blog/3029082
上一篇: ipld 博客分类: 区块链
下一篇: 关于线性基的一些肤浅理解与口胡
推荐阅读
-
iview 组件的封装
-
vue组件的挂载方式
-
C++中的事件Event(基于条件变量的封装)
-
Fragment的懒加载实现原理和封装
-
vue封装可实现选中、新增、修改、删除功能的树组件
-
Java对象的封装的目的,使用方法:属性私有,get/set.
-
JS的一些时间获取和计算公用方法封装
-
Android六大官方构架组件的基础使用(Lifecycle,LiveData,ViewModel,Room,Paging,Navigation)
-
电商数仓-(项目经验之Flume组件,日志采集Flume配置,Flume的ETL和分类型拦截器)
-
矢量化的HTML5拓扑图形组件设计 HTML5电力燃气工控WebSCADA