a-input输入框,苹果电脑(MAC)输入法的输入Bug
一、系统背景
我的项目使用的vue2.6.10 + ant-design of vue 1.7.8版本的框架,其实就是使用了jeecg的框架;然后再开发过程中没有使用过苹果电脑,所以没有测出这输入法的bug;
BUG:在MAC系统中,我的输入框输入“珠海”两个字,然后显示的拼音和中文,不是珠海两个字,但是,如果一个字一个字的输入,就没问题,连打就有问题;
二、问题解决和代码
检查发现,是在全局加了一个事件监听,main.js文件添加的,影响到了全局,所以把这个全局的事件监听注释掉,这个事件监听的主要作用是去除空格的;
代码:
mounted () {// 在全局监听 input 事件;去掉input的空格// document.body.addEventListener('input', this.removeSpacesFromInput, true);},render: h => h(App),//去掉input的空格// methods:{// removeSpacesFromInput(e) {// // 判断是否为 Ant Design 的 a-input 元素// if (e.target.tagName === 'INPUT') {// if (e.target.closest('.ant-input')) {// // 对 Ant Design 的 a-input 组件去除空格// e.target.value = e.target.value.replace(/\s+/g, '');// } else if (e.target.closest('.el-input__inner')) {// // 对 Element UI 的 el-input 组件去除空格// e.target.value = e.target.value.replace(/\s+/g, '');// }// }// }// },// //去掉input的空格// beforeDestroy() {// // 在组件销毁前移除事件监听// document.body.removeEventListener('input', this.removeSpacesFromInput, true);// }}).$mount('#app')
就是上面的代码影响到了,注释掉就没问题了!!!