gyyg-components 0.4.2 → 0.4.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gyyg-components",
3
- "version": "0.4.2",
3
+ "version": "0.4.3",
4
4
  "private": false,
5
5
  "main": "lib/gyyg-components.umd.js",
6
6
  "scripts": {
@@ -61,6 +61,10 @@ export default {
61
61
  type: Boolean,
62
62
  defalut: false,
63
63
  },
64
+ isSelectFirst: {
65
+ type: Boolean,
66
+ default: false,
67
+ },
64
68
  },
65
69
  data() {
66
70
  return {
@@ -81,16 +85,30 @@ export default {
81
85
  if (this.options instanceof Promise) {
82
86
  this.options.then((val) => {
83
87
  this.option = val.data || val;
84
- console.log(this.option);
88
+ if (this.isSelectFirst) {
89
+ if(this.option.length > 0){
90
+ this.handleChange(this.option[0][this.props.value]);
91
+ }
92
+ }
85
93
  });
86
94
  }
87
95
  if (typeof this.options == "function") {
88
96
  this.options().then((val) => {
89
97
  this.option = val.data || val;
98
+ if (this.isSelectFirst) {
99
+ if(this.option.length > 0){
100
+ this.handleChange(this.option[0][this.props.value]);
101
+ }
102
+ }
90
103
  });
91
104
  }
92
105
  } else {
93
106
  this.option = this.options;
107
+ if (this.isSelectFirst) {
108
+ if(this.option.length > 0){
109
+ this.handleChange(this.option[0][this.props.value]);
110
+ }
111
+ }
94
112
  }
95
113
  },
96
114
  deep: true,
@@ -99,6 +117,7 @@ export default {
99
117
  },
100
118
  methods: {
101
119
  handleChange(val) {
120
+ console.log(val);
102
121
  if (this.multiple) {
103
122
  this.selected = val;
104
123
  let info = this.option.filter((item) => val.includes(item[this.props.value]));