diff --git a/packages/mask-text/index.vue b/packages/mask-text/index.vue index 7752c73..12fd5ee 100644 --- a/packages/mask-text/index.vue +++ b/packages/mask-text/index.vue @@ -2,13 +2,13 @@ * @Author: zhaojinfeng 121016171@qq.com * @Date: 2023-07-23 16:27:37 * @LastEditors: zhaojinfeng 121016171@qq.com - * @LastEditTime: 2023-07-23 17:03:29 + * @LastEditTime: 2023-07-23 17:28:40 * @FilePath: \vue3\packages\mask-text\index.vue * @Description: 敏感数据隐藏组件 * --> @@ -23,17 +23,18 @@ const props = withDefaults(defineProps<{ right?: number }>(), { left: 0, right: 0 }) -const [value, toggle] = useToggle(false) +const [value, toggle] = useToggle(true) const data = computed(() => { const left = props.left < 0 ? 0 : props.left const right = props.right < 0 ? 0 : props.right const textLength = props.text.length - if (!props.text + if ( + !value.value + || !props.text || left > textLength || right > textLength || right + left > textLength - || value.value ) return props.text const rightIndex = textLength - right