Skip to content

Commit

Permalink
修改 grid 和table(Modify grid And Table)
Browse files Browse the repository at this point in the history
  • Loading branch information
HomWang committed Mar 8, 2020
1 parent 00186d0 commit b1b08f1
Show file tree
Hide file tree
Showing 6 changed files with 301 additions and 339 deletions.
42 changes: 23 additions & 19 deletions components/NInput.vue
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const {
export default {
name: "NInput",
install(Vue, theme) {
install (Vue, theme) {
selfInstall(Vue, theme, this);
},
Expand All @@ -49,7 +49,7 @@ export default {
size: {
type: String,
default: "sm",
validator: function(value) {
validator: function (value) {
return (
value === null ||
["xs", "sm", "base", "lg", "xl"].indexOf(value) !== -1
Expand All @@ -75,6 +75,7 @@ export default {
type: Boolean,
default: false
},
// 带有必填字段的表单
required: {
type: Boolean,
default: false
Expand Down Expand Up @@ -109,14 +110,17 @@ export default {
type: [String, Number],
default: null
},
// 可接受多个值的文件上传字段
multiple: {
type: Boolean,
default: false
},
// 只读
readonly: {
type: Boolean,
default: undefined
},
// 规定用于验证输入字段的模式
pattern: {
type: String,
default: null
Expand Down Expand Up @@ -234,15 +238,14 @@ export default {
}
},
data() {
data () {
return {
currentValue: this.value
};
},
watch: {
value(value) {
console.log("监听的value值:", value);
value (value) {
if (!value) {
this.$el.children[0].value = "";
}
Expand All @@ -256,7 +259,7 @@ export default {
* 输入框的默认类
* @return {Array}
*/
currentClass() {
currentClass () {
let classes = [
`${this.$options._componentTag}`,
`${this.$options._componentTag}-size-${this.size || "default"}`,
Expand Down Expand Up @@ -382,7 +385,7 @@ export default {
* icon的默认类
* @return {Array}
*/
iconCurrentClass() {
iconCurrentClass () {
let classes = [this.iconClass, this.icon];
// 判断之后
Expand Down Expand Up @@ -416,8 +419,9 @@ export default {
break;
}
if (this.clearable) {
if (this.clearable && this.currentValue) {
classes.push(this.clearableClass);
classes.push("n-icon-clean")
}
switch (this.status) {
Expand All @@ -436,33 +440,33 @@ export default {
},
methods: {
onBlur(e) {
onBlur (e) {
this.$emit("blur", e);
},
onFocus(e) {
onFocus (e) {
this.$emit("focus", e);
},
onInput(e) {
onInput (e) {
this.$emit("input", e.target.value);
},
onChange(e) {
onChange (e) {
if (this.currentValue !== e.target.value) {
this.$emit("change", e.target.value);
}
},
// 清除input的值
onClearable() {
onClearable () {
this.$emit("input", "");
this.$emit("change", "");
this.$emit("clear");
this.currentValue = "";
},
getAttributes() {
getAttributes () {
return {
id: this.id,
type: this.type,
Expand All @@ -483,13 +487,13 @@ export default {
};
},
getIconAttributes() {
getIconAttributes () {
return {
id: this.id
};
},
getDivAttributes() {
getDivAttributes () {
return {
id: this.id
};
Expand All @@ -500,7 +504,7 @@ export default {
* 渲染Input组件
* @return {String}
*/
inputToRender(createElement) {
inputToRender (createElement) {
return createElement(
"input",
{
Expand All @@ -522,7 +526,7 @@ export default {
* 根据Input的状态渲染的Icon组件
* @return {String}
*/
iconToRender(createElement) {
iconToRender (createElement) {
let [...newIconCurrentClass] = this.iconCurrentClass;
return this.$createElement(
"i",
Expand All @@ -539,7 +543,7 @@ export default {
}
},
render: function(createElement) {
render: function (createElement) {
return createElement(
"div",
{
Expand Down
Loading

0 comments on commit b1b08f1

Please sign in to comment.