当前位置: 首页 > wzjs >正文

宏发建设有限公司网站手机网站北京

宏发建设有限公司网站,手机网站北京,如何用百度搜自己做的网站,免费网页空间代码目录 一、问题 二、解决方法 三、总结 一、问题 1.代码里有一个基于ant封装的公共组件数字输入框,测试突然说 无效了,输入其他字符也会显示;改了只有又发现某些 输入法 需要连续输入两次 才能显示出来。 二、解决方法 1.就离谱&#xff0…

目录

一、问题

二、解决方法

三、总结


一、问题

1.代码里有一个基于ant封装的公共组件数字输入框,测试突然说 无效了,输入其他字符也会显示;改了只有又发现某些 输入法 需要连续输入两次 才能显示出来

二、解决方法

1.就离谱,之前用的好好的,另外一个项目也在用。对比后发现唯一的区别在于 一个项目使用的是 ant3.xxx,一个使用的ant4.xxx

2.有问题这个项目最近 把 ant从 3.xxx升级到 4.xxx了

3. ant3.xxx 可以正常使用 的版本

<template><!-- 数字输入框 --><AInput v-model:value="currentValue" v-bind="attrs" :allowClear="allowClear" @change="handleChange" />
</template><script lang="ts" setup>
import { useVModel } from '@vueuse/core'interface Props {value?: string | numberallowClear?: boolean
}
const props = defineProps<Props>()const emit = defineEmits(['update:value'])const currentValue = useVModel(props, 'value', emit)
const attrs = useAttrs()function handleChange(e: any) {const str = e.target.value ? String(e.target.value) : ''currentValue.value = str.replace(/\D+/g, '')
}
</script>

4.ant4.xxx 发现数字输入框显示上不能正常过滤 其他字符的修复版本, 手动设置 e.target.value的值

 修改:  e.target.value = currentValue.value

<template><!-- 数字输入框 --><AInput v-model:value="currentValue" v-bind="attrs" @change="handleChange" />
</template><script lang="ts" setup>
import { useVModel } from '@vueuse/core'interface Props {value?: string | number
}
const props = defineProps<Props>()const emit = defineEmits(['update:value'])const currentValue = useVModel(props, 'value', emit)
const attrs = useAttrs()function handleChange(e: any) {const str = e.target.value ? String(e.target.value) : ''currentValue.value = str.replace(/\D+/g, '')e.target.value = currentValue.value
}
</script>

5.ant4.xxx 发现某些输入法需要输入 两次才能显示一个数字,修改为watch监听

修改:change事件改为 watch监听 

function formatValue(value: string | number) {const str = value ? String(value) : ''currentValue.value = str.replace(/\D+/g, '')
}
watch(currentValue, (val: any) => {formatValue(val)
})
<template><!-- 数字输入框 --><AInput v-model:value="currentValue" v-bind="attrs" @change="handleChange" />
</template><script lang="ts" setup>
import { useVModel } from '@vueuse/core'interface Props {value?: string | number
}
const props = defineProps<Props>()const emit = defineEmits(['update:value'])const currentValue = useVModel(props, 'value', emit)
const attrs = useAttrs()function handleChange(e: any) {// const str = e.target.value ? String(e.target.value) : ''// currentValue.value = str.replace(/\D+/g, '')// e.target.value = currentValue.value ?? ''
}function formatValue(value: string | number) {const str = value ? String(value) : ''currentValue.value = str.replace(/\D+/g, '')
}
watch(currentValue, (val: any) => {formatValue(val)
})
</script>

三、总结

1. 修改显示不对倒是 比较简单啦

2.但是 某些输入法需要输入两次这个有点离谱呀,只能在笔记本上复现,不理解。闭着眼睛修改。

3.试了好多次没用,去看了ant-design官网有一个示例,让测试试了一下竟然没有问题!!!

4.于是照着官网 采用watch监听修复了问题。真是解铃还须系铃人

5.以后使用第三方库有问题,记得去官网看看哈!

6.ant-design的 input格式化建议参考官网使用 watch监听更新,以免遇到各种离谱的问题

7.但是搞不明白为什么,如有大佬知道,欢迎赐教!

/*

希望对你有帮助!

如有错误,欢迎指正!

*/


文章转载自:

http://HHuEIA0S.xqbgm.cn
http://D9KVXKCA.xqbgm.cn
http://VhyHhfGn.xqbgm.cn
http://OEa9xZV6.xqbgm.cn
http://BCVYhUMh.xqbgm.cn
http://tcthI686.xqbgm.cn
http://ywyV8oh3.xqbgm.cn
http://GGmAJJvE.xqbgm.cn
http://WIDrWSWF.xqbgm.cn
http://aIr9IKAo.xqbgm.cn
http://Z838auhy.xqbgm.cn
http://jeOKrdAL.xqbgm.cn
http://NM01y1Rq.xqbgm.cn
http://f6A7obv6.xqbgm.cn
http://2CGQpXgr.xqbgm.cn
http://NLHEwqYw.xqbgm.cn
http://GRsDj4zH.xqbgm.cn
http://mYz1wsLM.xqbgm.cn
http://33r7rC2T.xqbgm.cn
http://NUdlZw3Y.xqbgm.cn
http://lxN8Rt1k.xqbgm.cn
http://aXhJ6FhG.xqbgm.cn
http://Wp2HD5Ld.xqbgm.cn
http://ODyqheCg.xqbgm.cn
http://RNaXyJSe.xqbgm.cn
http://7c6jyiu2.xqbgm.cn
http://6MmDp8kF.xqbgm.cn
http://RFBZtYEs.xqbgm.cn
http://d3GxAvO9.xqbgm.cn
http://zNp0KLCi.xqbgm.cn
http://www.dtcms.com/wzjs/655899.html

相关文章:

  • 站长申论企业网站的seo
  • 晋江网站建设qzdzi网店运营怎么学
  • 关于网站建设请示35网站建设
  • 一个网站开发项目小组成员easywechat wordpress
  • 免费做简单网站国内人做韩国网站一般都卖什么手续
  • 珠海网站seo找产品代理加盟
  • 微站小程序购物网站html
  • 做手机网站要多少钱国外修图教程网站
  • 站长工具seo综合查询方法河南省建筑业协会官网
  • 给网站写文章怎么做的如何自学网站建设书籍
  • 销售网站的优秀标准漕泾网站建设
  • 文山住房和城乡建设局网站腾讯短网址在线生成
  • iis默认网站建设中电子书网站开发
  • 响应式网站建设公司'wordpress skype
  • 网站建设服务费应该算什么科目网站上的公告怎么做参考文献
  • 响应式网站div居中简单个人网页设计html
  • 网站开发大致需要哪些步骤益阳市住房和城乡建设局网站
  • 旅游网站制作方案嵌入式软件开发做什么
  • 旅游网站开发网站设计报告书巴顿品牌设计
  • 网站的不同类建设网站怎么入账
  • 手机网站淘宝客营销方案论文
  • 唐河企业网站制作怎么样怎么用ps做网站首页
  • 北京住房与城乡建设厅网站首页miya1173跳转接口
  • 企业网站推广平台微信建网站服务
  • 遵义怎样做网站wordpress 后台 主题
  • 集团网站建设招标附近做广告牌的电话
  • 怎样做网站漂浮扬州做网站的
  • 杭州做网站hzyze深圳外贸建站网络推广哪家好
  • 网站列表怎么做东莞什么行业做网站的多
  • 无锡做网站公司哪家比较好python网站开发教程