Commit 6edd64f1 by GoldenZqqqq

feat: DictTag组件加字符串分隔符props,更灵活定义split字符串的分隔符

parent c015b2e8
......@@ -15,6 +15,11 @@ export default defineComponent({
value: {
type: [String, Number, Boolean, Array],
required: true
},
// 字符串分隔符 只有当 props.value 传入值为字符串时有效
sepSymbol: {
type: String as PropType<string>,
default: ','
}
},
setup(props) {
......@@ -23,9 +28,9 @@ export default defineComponent({
if (isNumber(props.value)) {
return [String(props.value)]
}
// 2.是字符串(进一步判断是否有','
// 2.是字符串(进一步判断是否有包含分隔符号 -> props.sepSymbol
else if (isString(props.value)) {
return props.value.includes(',') ? props.value.split(',') : [String(props.value)]
return props.value.split(props.sepSymbol)
}
// 3.数组
else if (isArray(props.value)) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment