34 lines
1.1 KiB
JavaScript
34 lines
1.1 KiB
JavaScript
// my-component.js
|
||
// 引入全局 Vue 对象(因在 HTML 中通过 script 引入,Vue 已挂载到 window)
|
||
const { defineComponent, ref } = Vue;
|
||
import { itemBottom } from "../item-bottom/item-bottom.js";
|
||
import { itemHead } from "../item-head/item-head.js";
|
||
|
||
// 定义组件(直接使用模板)
|
||
export const itemForum = defineComponent({
|
||
name: "item-forum",
|
||
props: {
|
||
itemdata: {
|
||
type: Object,
|
||
default: () => {},
|
||
},
|
||
},
|
||
|
||
setup(props) {
|
||
let res = props.itemdata || {};
|
||
res.content = res?.content?.replace(/\[.*?\]/g, "");
|
||
res.content = res?.content?.replace(/\<.*?\>/g, "");
|
||
res.content = res?.content?.replace(/\[.*?\../g, "");
|
||
|
||
let item = ref({ ...res });
|
||
return { item };
|
||
},
|
||
|
||
components: {
|
||
itemBottom,
|
||
itemHead,
|
||
},
|
||
|
||
template: `<div class="item-box item-forum"> <item-head :itemdata="item"></item-head> <div v-if="item.title" class="title">{{ item.title }}</div> <div class="message two-line-display">{{ item.content }}</div> <item-bottom :itemdata="item"></item-bottom></div>`,
|
||
});
|