update
This commit is contained in:
@@ -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(() => {
|
||||
|
||||
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user