js的改值触发事件和键盘弹起触发事件个人感觉差不多

本文介绍了一种使用jQuery实现的市场ID输入事件处理方法,通过按键弹起触发更新ViewModel中的市场ID属性,并调用获取主要信息的函数。
  //$('#txt_marketId').on('input propertychange', function (e) {
    //    var marketId = $('#txt_marketId').val();
    //    ViewModel.conditionModel.marketId = marketId;
    //    IndexPager.getInfoToMainFine();
    //});
  
    
    
    // 按键弹起时触发的事件; 
    $("#txt_marketId").keyup(function () {       
        var marketId = $('#txt_marketId').val();
        ViewModel.conditionModel.marketId = marketId;
        IndexPager.getInfoToMainFine();

    });

转载请注明出处: https://mp.youkuaiyun.com/postedit/82702874

const doOpen = rect => { console.log('🚀 ~ rect:', rect) // const res = uni.getSystemInfoSync() const res = uni.getWindowInfo?.() || {} console.log('🚀 ~ res:', res) const windowHeight = Number(res.windowHeight) console.log('🚀 ~ windowHeight 视口高度:', windowHeight) const windowWidth = Number(res.windowWidth) console.log('🚀 ~ windowWidth 视口宽度:', windowWidth) let maxHeight = null if (props.maxHeight < (props.data.length + 1) * 46) { maxHeight = props.maxHeight } else { maxHeight = (props.data.length + 1) * 46 } console.log('🚀 ~ maxHeight 弹窗最大高度:', maxHeight) const menuWidth = 215 const rightGap = 12 const spaceBelow = windowHeight - rect.bottom console.log('🚀 ~ spaceBelow: 安全距离', spaceBelow) const spaceAbove = rect.top console.log('🚀 ~ spaceAbove: 安全距离', spaceAbove) const isBothDirectionsInsufficient = spaceAbove < maxHeight && spaceBelow < maxHeight console.log('🚀 ~ isBothDirectionsInsufficient:', isBothDirectionsInsufficient) let finalTop, finalLeft, finalTransform if (isBothDirectionsInsufficient) { // 上下空间都不够 → 居中显示 finalTop = windowHeight / 2 finalTransform = 'translate(0, -50%)' finalLeft = windowWidth - menuWidth - rightGap if (finalLeft < 0) finalLeft = 0 } else { // 正常方向展开 const needUpward = spaceBelow < maxHeight console.log('🚀 ~ needUpward:', needUpward) if (needUpward) { // 弹窗在上方,确保不覆盖触发元素 finalTop = rect.top - maxHeight + 25 // 可以添加一个小的间距,避免紧贴太近 finalTop = Math.max(0, finalTop - 5) } else { // 弹窗在下方,紧贴触发元素底部 finalTop = rect.bottom } finalTransform = needUpward ? '' : '' finalLeft = windowWidth - menuWidth - rightGap if (finalLeft < 0) finalLeft = 0 } // 移除不必要的偏移 top.value = finalTop console.log('🚀 ~ top.value:', top.value) left.value = finalLeft console.log('🚀 ~ left.value:', left.value) position.value = finalTransform console.log('🚀 ~ position.value:', position.value) visible.value = true emit('open', props.modelValue, props.trigger) nextTick(() => { bindOutsideClickListener() bindScrollListener() }) } 安卓手机的定位在needUpward: true的候,没有紧贴出发展开的元素
最新发布
11-14
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值