support InputNumber
support InputNumber
This commit is contained in:
parent
456daf3492
commit
c97c42ab2e
8 changed files with 50 additions and 14 deletions
|
@ -11,4 +11,6 @@ value 改为了 label,使用 v-model,废弃 checked
|
||||||
### Switch
|
### Switch
|
||||||
废弃checked, 改为了 value,使用 v-model
|
废弃checked, 改为了 value,使用 v-model
|
||||||
### Badge
|
### Badge
|
||||||
class 改为了 className
|
class 改为了 className
|
||||||
|
### InputNumber
|
||||||
|
使用 v-model
|
|
@ -31,7 +31,7 @@
|
||||||
- [ ] TimePicker
|
- [ ] TimePicker
|
||||||
- [ ] Cascader
|
- [ ] Cascader
|
||||||
- [ ] Transfer
|
- [ ] Transfer
|
||||||
- [ ] InputNumber
|
- [x] InputNumber
|
||||||
- [ ] Rate
|
- [ ] Rate
|
||||||
- [ ] Upload
|
- [ ] Upload
|
||||||
- [ ] Form
|
- [ ] Form
|
||||||
|
|
|
@ -92,7 +92,8 @@
|
||||||
return {
|
return {
|
||||||
focused: false,
|
focused: false,
|
||||||
upDisabled: false,
|
upDisabled: false,
|
||||||
downDisabled: false
|
downDisabled: false,
|
||||||
|
currentValue: this.value
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
|
@ -164,7 +165,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
const targetVal = Number(e.target.value);
|
const targetVal = Number(e.target.value);
|
||||||
let val = Number(this.value);
|
let val = Number(this.currentValue);
|
||||||
const step = Number(this.step);
|
const step = Number(this.step);
|
||||||
if (isNaN(val)) {
|
if (isNaN(val)) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -196,9 +197,11 @@
|
||||||
},
|
},
|
||||||
setValue (val) {
|
setValue (val) {
|
||||||
this.$nextTick(() => {
|
this.$nextTick(() => {
|
||||||
this.value = val;
|
this.currentValue = val;
|
||||||
|
this.$emit('input', val);
|
||||||
this.$emit('on-change', val);
|
this.$emit('on-change', val);
|
||||||
this.$dispatch('on-form-change', val);
|
// todo 事件
|
||||||
|
// this.$dispatch('on-form-change', val);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
focus () {
|
focus () {
|
||||||
|
@ -224,7 +227,7 @@
|
||||||
|
|
||||||
if (isValueNumber(val)) {
|
if (isValueNumber(val)) {
|
||||||
val = Number(val);
|
val = Number(val);
|
||||||
this.value = val;
|
this.currentValue = val;
|
||||||
|
|
||||||
if (val > max) {
|
if (val > max) {
|
||||||
this.setValue(max);
|
this.setValue(max);
|
||||||
|
@ -234,7 +237,7 @@
|
||||||
this.setValue(val);
|
this.setValue(val);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
event.target.value = this.value;
|
event.target.value = this.currentValue;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
changeVal (val) {
|
changeVal (val) {
|
||||||
|
@ -250,11 +253,14 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
compiled () {
|
mounted () {
|
||||||
this.changeVal(this.value);
|
this.changeVal(this.currentValue);
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
value (val) {
|
value (val) {
|
||||||
|
this.currentValue = val;
|
||||||
|
},
|
||||||
|
currentValue (val) {
|
||||||
this.changeVal(val);
|
this.changeVal(val);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,7 +18,7 @@ import Checkbox from './components/checkbox';
|
||||||
// import Form from './components/form';
|
// import Form from './components/form';
|
||||||
import Icon from './components/icon';
|
import Icon from './components/icon';
|
||||||
import Input from './components/input';
|
import Input from './components/input';
|
||||||
// import InputNumber from './components/input-number';
|
import InputNumber from './components/input-number';
|
||||||
// import LoadingBar from './components/loading-bar';
|
// import LoadingBar from './components/loading-bar';
|
||||||
// import Menu from './components/menu';
|
// import Menu from './components/menu';
|
||||||
// import Message from './components/message';
|
// import Message from './components/message';
|
||||||
|
@ -74,7 +74,7 @@ const iview = {
|
||||||
Icon,
|
Icon,
|
||||||
// iInput: Input,
|
// iInput: Input,
|
||||||
Input,
|
Input,
|
||||||
// InputNumber,
|
InputNumber,
|
||||||
// LoadingBar,
|
// LoadingBar,
|
||||||
// Menu,
|
// Menu,
|
||||||
// MenuGroup: Menu.Group,
|
// MenuGroup: Menu.Group,
|
||||||
|
|
|
@ -25,6 +25,7 @@ li + li { border-left: solid 1px #bbb; padding-left: 10px; margin-left: 10px; }
|
||||||
<li><router-link to="/alert">Alert</router-link></li>
|
<li><router-link to="/alert">Alert</router-link></li>
|
||||||
<li><router-link to="/badge">Badge</router-link></li>
|
<li><router-link to="/badge">Badge</router-link></li>
|
||||||
<li><router-link to="/tag">Tag</router-link></li>
|
<li><router-link to="/tag">Tag</router-link></li>
|
||||||
|
<li><router-link to="/input-number">InputNumber</router-link></li>
|
||||||
</ul>
|
</ul>
|
||||||
</nav>
|
</nav>
|
||||||
<router-view></router-view>
|
<router-view></router-view>
|
||||||
|
|
|
@ -64,6 +64,10 @@ const router = new VueRouter({
|
||||||
{
|
{
|
||||||
path: '/tag',
|
path: '/tag',
|
||||||
component: require('./routers/tag.vue')
|
component: require('./routers/tag.vue')
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: '/input-number',
|
||||||
|
component: require('./routers/input-number.vue')
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
});
|
});
|
||||||
|
|
25
test/routers/input-number.vue
Normal file
25
test/routers/input-number.vue
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
<template>
|
||||||
|
<div>
|
||||||
|
<Input-number :max="10" :min="-1" v-model="v1"></Input-number>
|
||||||
|
{{ v1 }}
|
||||||
|
<div @click="c">change v1</div>
|
||||||
|
<Input-number disabled :max="10" :min="1" :step="1.2" v-model="v2"></Input-number>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
<script>
|
||||||
|
export default {
|
||||||
|
props: {},
|
||||||
|
data () {
|
||||||
|
return {
|
||||||
|
v1: 1,
|
||||||
|
v2: 1
|
||||||
|
};
|
||||||
|
},
|
||||||
|
computed: {},
|
||||||
|
methods: {
|
||||||
|
c () {
|
||||||
|
this.v1 = 5;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
</script>
|
|
@ -35,9 +35,7 @@
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<script>
|
<script>
|
||||||
import { Tag, Modal, iButton } from 'iview';
|
|
||||||
export default {
|
export default {
|
||||||
components: { Tag, Modal, iButton },
|
|
||||||
data () {
|
data () {
|
||||||
return {
|
return {
|
||||||
modal1: false,
|
modal1: false,
|
||||||
|
|
Loading…
Add table
Reference in a new issue