fix: text未定义时的报错问题

This commit is contained in:
2023-07-23 17:47:41 +08:00
parent e204b1bd42
commit a677dd8cf1

View File

@ -26,13 +26,13 @@ const props = withDefaults(defineProps<{
const [value, toggle] = useToggle(true)
const data = computed(() => {
if (!value.value || !props.text)
return ''
const left = props.left < 0 ? 0 : props.left
const right = props.right < 0 ? 0 : props.right
const textLength = props.text.length
if (
!value.value
|| !props.text
|| left > textLength
if (left > textLength
|| right > textLength
|| right + left > textLength
)