diff --git a/src/utils/util.js b/src/utils/util.js index 7d131a35..90c6ac0a 100644 --- a/src/utils/util.js +++ b/src/utils/util.js @@ -44,3 +44,12 @@ export function isObject(value) { export function datetimeFormat(value, pattern = 'YYYY-MM-DD HH:mm') { return moment(value).format(pattern) } + +// decode html tag +export function decodeHTML(html) { + let elem = document.createElement('div') + elem.innerHTML = html + const output = elem.innerText || elem.textContent + elem = null + return output +} diff --git a/src/views/comment/components/CommentTab.vue b/src/views/comment/components/CommentTab.vue index e5674145..50dd6f48 100644 --- a/src/views/comment/components/CommentTab.vue +++ b/src/views/comment/components/CommentTab.vue @@ -441,6 +441,8 @@ import { mixin, mixinDevice } from '@/utils/mixin.js' import CommentDetail from './CommentDetail' import marked from 'marked' import commentApi from '@/api/comment' +import { decodeHTML } from '@/utils/util' + const postColumns = [ { title: '昵称', @@ -576,7 +578,7 @@ export default { formattedComments() { return this.comments.map(comment => { comment.statusProperty = this.commentStatus[comment.status] - comment.content = marked(comment.content) + comment.content = marked(decodeHTML(comment.content)) return comment }) } diff --git a/src/views/comment/components/TargetCommentTree.vue b/src/views/comment/components/TargetCommentTree.vue index adb09d17..33676013 100644 --- a/src/views/comment/components/TargetCommentTree.vue +++ b/src/views/comment/components/TargetCommentTree.vue @@ -97,6 +97,8 @@