Skip to content

Commit 29bcfd0

Browse files
committed
array fill polyfill
1 parent addc13e commit 29bcfd0

File tree

4 files changed

+17
-38
lines changed

4 files changed

+17
-38
lines changed

dist/vue-custom-input.js

Lines changed: 7 additions & 35 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/vue-custom-input.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/components/Input.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
</div>
99
</template>
1010
<script>
11-
import { assignObj } from '../module/util'
11+
import { assignObj, arrayFill } from '../module/util'
1212
export default {
1313
name: 'custom-input',
1414
props: {
@@ -74,7 +74,7 @@
7474
},
7575
data() {
7676
return {
77-
spanValue: new Array(this.inputNumber).fill(''),
77+
spanValue: arrayFill(new Array(this.inputNumber), ''),
7878
activeIndex: undefined
7979
}
8080
},

src/module/util.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
export const arrayFill = (arr, fillVal) => {
2+
for(let i = 0, len = arr.length; i < len; i++){
3+
arr[i] = fillVal;
4+
}
5+
return arr;
6+
}
7+
18
/*
29
object-assign
310
*/

0 commit comments

Comments
 (0)