65 lines
1.2 KiB
Vue
65 lines
1.2 KiB
Vue
<template>
|
||
<view class="tag-list">
|
||
<view
|
||
v-for="(item, index) in tags"
|
||
:key="index"
|
||
class="tag-item"
|
||
@click="handleClick(item)"
|
||
>
|
||
<text class="tag-text">{{ item }}</text>
|
||
</view>
|
||
</view>
|
||
</template>
|
||
|
||
<script setup>
|
||
import { ref, nextTick, defineEmits } from "vue";
|
||
import { onMounted } from "vue";
|
||
import { SCROLL_TO_BOTTOM } from "@/constant/constant";
|
||
const props = defineProps({
|
||
question: {
|
||
type: String,
|
||
default: "",
|
||
},
|
||
});
|
||
|
||
const tags = ref([]);
|
||
const emits = defineEmits(["replySent"]);
|
||
|
||
const handleClick = (item) => {
|
||
emits("replySent", item);
|
||
};
|
||
|
||
onMounted(() => {
|
||
tags.value = props.question.split(/[&|;]/).filter((tag) => tag.trim() !== "");
|
||
nextTick(() => {
|
||
setTimeout(() => {
|
||
uni.$emit(SCROLL_TO_BOTTOM, true);
|
||
}, 300);
|
||
});
|
||
});
|
||
</script>
|
||
|
||
<style scoped lang="scss">
|
||
.tag-list {
|
||
display: flex;
|
||
flex-wrap: wrap;
|
||
padding: 6px 12px;
|
||
}
|
||
|
||
.tag-item {
|
||
background-color: #ffffff;
|
||
border-radius: 8px;
|
||
padding: 4px 10px;
|
||
margin-right: 8px;
|
||
margin-bottom: 8px;
|
||
display: inline-flex;
|
||
align-items: center;
|
||
justify-content: center;
|
||
}
|
||
|
||
.tag-text {
|
||
color: #00a6ff; /* 蓝色文字,可根据设计调整 */
|
||
font-size: 14px;
|
||
}
|
||
</style>
|