You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
apply-assistant-v3/root/components/chatEvent/message.vue

68 lines
1.4 KiB
Vue

<template>
<view class="g-components-chat-message g_fs_17 g_flex_row_start" >
<div class="g_flex_column_center">
{{displayedMessage}}
</div>
</view>
</template>
<script>
export default {
props: {
cusMessage: {
type: String,
default: () => {
return '';
},
},
isRender:{
default: () => {
return 0;
},
}
},
data(){
return {
isShow:0,
displayedMessage: ''
}
},
watch: {
cusMessage: {
handler(newVal) {
console.log('newVal',newVal)
const hasDot = String(newVal).endsWith('。');
const messageWithoutDot = hasDot ? newVal.slice(0, -1) : newVal;
this.displayedMessage = messageWithoutDot;
if (this.isShow) {
this.displayedMessage = messageWithoutDot + '...';
} else {
this.displayedMessage = hasDot ? messageWithoutDot + '。' : messageWithoutDot;
}
},
immediate: true
},
'isRender': {
handler(newVal) {
this.isShow = newVal;
if(this.cusMessage){
let _str = String(this.cusMessage);
const hasDot = _str.endsWith('。');
const messageWithoutDot = hasDot ? _str.slice(0, -1) : _str;
this.displayedMessage = this.isShow ? messageWithoutDot + '...' : (hasDot ? messageWithoutDot + '。' : messageWithoutDot);
}
},
immediate: true
}
},
created(){
this.isShow = this.isRender;
},
methods:{
}
};
</script>
<style>
</style>