diff --git a/root/components/chatEvent/message.vue b/root/components/chatEvent/message.vue index 503922a..4f155be 100644 --- a/root/components/chatEvent/message.vue +++ b/root/components/chatEvent/message.vue @@ -31,7 +31,7 @@ cusMessage: { handler(newVal) { console.log('newVal',newVal) - const hasDot = newVal.endsWith('。'); + const hasDot = String(newVal).endsWith('。'); const messageWithoutDot = hasDot ? newVal.slice(0, -1) : newVal; this.displayedMessage = messageWithoutDot; if (this.isShow) { @@ -45,9 +45,12 @@ 'isRender': { handler(newVal) { this.isShow = newVal; - const hasDot = this.cusMessage.endsWith('。'); - const messageWithoutDot = hasDot ? this.cusMessage.slice(0, -1) : this.cusMessage; - this.displayedMessage = this.isShow ? messageWithoutDot + '...' : (hasDot ? messageWithoutDot + '。' : messageWithoutDot); + 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 }