完成选中标记&描述解析

This commit is contained in:
BTMuli
2023-06-17 21:56:01 +08:00
parent 59f66079e8
commit 486109b899
3 changed files with 46 additions and 12 deletions

View File

@@ -18,7 +18,7 @@
</div>
</template>
<template #desc>
<span>{{ props.modelValue.description }}</span>
<span v-html="parseDesc(props.modelValue.description)" />
</template>
</TucDetailDesc>
</template>
@@ -32,6 +32,20 @@ interface TucDetailDescConstellationProps {
}
const props = defineProps<TucDetailDescConstellationProps>();
// 解析描述
function parseDesc (desc: string): string {
const reg = /<color=(.*?)>(.*?)<\/color>/g;
let match = reg.exec(desc);
while (match) {
const color = match[1];
const text = match[2];
desc = desc.replace(match[0], `<span style="color: ${color}">${text}</span>`);
match = reg.exec(desc);
}
desc = desc.replace(/\\n/g, "<br />");
return desc;
}
</script>
<style lang="css" scoped>
.tuc-ddc-content {