《Vue.j实战》一书 p106 页练习1和练习2试做

练习1 :在输入框聚焦时,增加对键盘上下按键的支持,相当于加1 和减lo
练习2 :增加一个控制步伐的prop-step,比如设置为10 ,点击加号按钮, 一次增加10 。

Demo在线效果地址

 

练习1:在inputNumber.vue中,给input添加keyup事件绑定,如下:

        @keyup.down="handleDown"
        @keyup.up="handleUp"

练习2:父组件向inputnumber组件传入 step prop,

        <button
        @click="handleStepUp"
        :disabled="currentValue >= max">+ 10</button>
        handleStepUp(){
            if(this.currentValue >= this.max) return;
            this.currentValue += this.step;

 

posted @ 2019-08-02 14:37  sx00xs  阅读(394)  评论(0编辑  收藏  举报