12345678910111213141516171819202122232425262728293031323334353637383940414243444546 |
- <script lang="ts" setup>
- import { marked } from 'marked'
- import { ref } from 'vue'
- const props = defineProps({
- body: {
- type: Object,
- default: () => {}
- }
- })
- const text = ref('')
- const timer: any = ref()
- console.log(props.body.messageProps)
- const content = () => {
- const tempText = props.body.messageProps.text
- const len = tempText.length
- let num = 0
- let string = ''
- timer.value = setInterval(() => {
- if (num >= len) {
- clearInterval(timer.value)
- timer.value = null
- // this.saveHistory(this.preRecord)
- // resolve(true)
- return
- }
- // 持续保持滚动最底
- if (num % 10 === 0) {
- setTimeout(() => {
- // this.messageScroll()
- })
- }
- string = `${string}${tempText[num]}`
- text.value = marked(string) as string
- num++
- }, 50)
- }
- content()
- </script>
- <template>
- <div v-html="text"></div>
- </template>
- <style scoped lang="less"></style>
|