uni-app iOS nvue界面 input 使用disabled后 事件不能向上传递
uni-app iOS nvue界面 input 使用disabled后 事件不能向上传递
| 项目信息 | 详情 |
|---|---|
| 产品分类 | uniapp/App |
| PC开发环境操作系统 | Mac |
| PC开发环境操作系统版本号 | 13.3.1 |
| HBuilderX类型 | 正式 |
| HBuilderX版本号 | 3.8.12 |
| 手机系统 | iOS |
| 手机系统版本号 | iOS 15 |
| 手机厂商 | 苹果 |
| 手机机型 | 7p |
| 页面类型 | nvue |
| vue版本 | vue2 |
| 打包方式 | 云端 |
| 项目创建方式 | HBuilderX |
示例代码:
<view @click='click>
<input disabled></input>
</view>
click事件无效
操作步骤:
必现
预期结果:
input禁用时候 nvue可以事件冒泡
实际结果:
无效
bug描述:
input 在iOS nvue界面 使用disabled后 事件不能向上传递
更多关于uni-app iOS nvue界面 input 使用disabled后 事件不能向上传递的实战教程也可以访问 https://www.itying.com/category-93-b0.html
搞错了 是安卓平台不行 ios可以
更多关于uni-app iOS nvue界面 input 使用disabled后 事件不能向上传递的实战教程也可以访问 https://www.itying.com/category-93-b0.html
在 uni-app 的 nvue 页面中,input 组件使用 disabled 属性后,确实可能会导致事件无法向上传递。这是因为 disabled 属性会禁用输入框的交互,包括点击、触摸等事件。
解决方案
-
使用
readonly替代disabled
如果你只是希望用户不能修改输入框的内容,但仍然希望保留事件的传递,可以使用readonly属性代替disabled。<input type="text" readonly />readonly属性会阻止用户修改输入框的内容,但不会阻止事件的传递。 -
手动处理事件
如果你必须使用disabled,并且需要处理事件,可以在父元素上监听事件,然后手动处理。<view [@tap](/user/tap)="handleTap"> <input type="text" disabled /> </view>export default { methods: { handleTap() { // 处理点击事件 console.log('Input was clicked'); } } } -
使用
pointer-events样式
你可以通过 CSS 的pointer-events属性来控制元素的点击事件是否生效。将pointer-events设置为none可以禁用元素的点击事件,但仍然保留事件传递。<input type="text" disabled style="pointer-events: none;" />

