vue & button & refs & click & bug

vue & button & refs & click & bug

$refs.btn.click() ???

vue & refs

$refs.btn.$emit("click")

https://vuejs.org/v2/api/#vm-refs
https://vuejs.org/v2/api/#ref

https://vuejs.org/v2/guide/components-edge-cases.html#Accessing-Child-Component-Instances-amp-Child-Elements

740516-20190216151511084-460395892.png

$emit("click") & click()

ok

https://codepen.io/webgeeker/pen/rPQyMN?editors=1010

740516-20190216145210705-1637678407.png

https://codepen.io/webgeeker/pen/BMGWmq?editors=1010

740516-20190216145427063-894701058.png

bug

https://codepen.io/webgeeker/pen/vbQxZW?editors=1010

740516-20190216145116989-1551741178.png

vue & emit

https://vuejs.org/v2/api/#vm-emit


this.$refs.btn.$emit("click"')

this.$refs.inputResult.$emit('click')

http://www.imooc.com/wenda/detail/418881

image


OK

vue & keyboard Shortcut Keys

image


    // shortcut keys
    keyboardShortcutKeys() {
        // // operType: "1",// 0 上一页; 1 下一页
        let that = this;
        // bug ??? range conflict ???
        let body = document.querySelector(`body`);
        // let body = document.querySelector(`[data-body="common-handle"]`);
        let bindFlag = body.dataset.bindFlag;
        if (bindFlag === "true") {
            // console.log(`only need binding once!`);
        } else {
            body.dataset.bindFlag = "true";
            // bind once
            body.addEventListener("keyup", function(e) {
                let key = e.which || e.keyCode;
                if(e.which === 17) {
                    // init
                    this.isCtrlPressed = false;
                }
            });
            body.addEventListener("keydown", function(e) {
                let key = e.which || e.keyCode;
                if(e.which === 17) {
                    this.isCtrlPressed = true;
                }
                let isCtrl = this.isCtrlPressed;
                if(e.which === 83 && isCtrl) {
                    if (that.onClickButton) {
                        that.onClickButton(`save`);
                    }
                }
                if(e.which === 68 && isCtrl) {
                    if (that.clickGetNewsInfos) {
                        if (!that.isFirstNews) {
                            // that.clickGetNewsInfos(`prev`);
                            // that.$refs.commom_handle_prev.click();
                            that.$refs.commom_handle_prev.$emit("click");
                            // that.$refs["commom_handle_prev"].click();
                            console.log(`prev btn click ok!`);
                        } else {
                            // btn bug
                            console.log(`prev btn bug!`);
                        }
                    }
                }
                if(e.which === 70 && isCtrl) {
                    if (that.clickGetNewsInfos) {
                        if (!that.isLastNews) {
                            // that.clickGetNewsInfos(`next`);
                            // that.$refs.commom_handle_next.click();
                            that.$refs.commom_handle_next.$emit("click");
                            // that.$refs["commom_handle_next"].click();
                            console.log(`next btn click ok!`);
                        } else {
                            // btn bug
                            console.log(`next btn bug!`);
                        }
                    }
                }
                if(e.which === 88 && isCtrl) {
                    if (that.clickShowResureModal) {
                        that.clickShowResureModal(`passed`);
                    }
                }
            });
        }
    },

转载于:https://www.cnblogs.com/xgqfrms/p/10387125.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值