This commit is contained in:
2025-06-19 20:58:52 +08:00
parent 64e995eb70
commit be7fec6b5a
10 changed files with 125 additions and 55 deletions

View File

@@ -1,16 +1,34 @@
<script setup lang="ts">
import {nextTick, ref, useTemplateRef} from "vue";
<script setup>
import {nextTick, ref, useTemplateRef, watch} from "vue";
import {Message} from "@arco-design/web-vue";
const {limit} = defineProps({
limit: {
type: Number,
default: 5,
}
});
const inputTagRef = useTemplateRef('inputTagRef');
const modelValue = defineModel();
const input = ref('');
watch(
() => modelValue.value,
(val) => {
if (val) {
if (val.length > limit) {
val.length = limit;
Message.warning(`最多可设置${limit}个话题`)
}
}
},
{deep: true}
)
const changeInput = (e) => {
if (e.match(/#(\S+?)(?=\s)/g)) {
if (modelValue.value === void 0) {
console.log('进来了')
}
console.log(modelValue.value)
modelValue.value.push(...e.match(/#(\S+?)(?=\s)/g).map(tag => tag.slice(1)));
input.value = null;
nextTick(() => {

View File

@@ -12,7 +12,7 @@ const {color, content} = defineProps({
</script>
<template>
<a-tooltip :content="content">
<a-tooltip :content="content" v-if="content">
<a-badge>
<template v-slot:content>
<icon-question-circle :style="{ verticalAlign: 'middle', color: 'rgb(var(--primary-6))' }"/>
@@ -24,6 +24,10 @@ const {color, content} = defineProps({
</a-tag>
</a-badge>
</a-tooltip>
<a-tag v-else :color="color" class="cursor-pointer">
<slot></slot>
</a-tag>
</template>
<style scoped>