- 将硬编码的详情页链接改为通过item.url统一管理 - 将评论区域的div改为可点击的a标签 - 调整图标容器的样式结构,增加定位和尺寸控制 - 修复标签过滤逻辑,避免空值导致的错误
41 lines
1.3 KiB
JavaScript
41 lines
1.3 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: () => {},
|
||
},
|
||
page: {
|
||
type: String,
|
||
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 });
|
||
|
||
item.value['url'] = '/details/' + item.value.uniqid;
|
||
|
||
return { item };
|
||
},
|
||
|
||
components: {
|
||
itemBottom,
|
||
itemHead,
|
||
},
|
||
|
||
template: `<div class="item-box item-forum"> <item-head :itemdata="item" :page="page"></item-head> <a v-if="item.title" class="title" :href="item.url" target="_blank">{{ item.title }}</a> <a class="message two-line-display" :href="item.url" target="_blank">{{ item.content }}</a> <item-bottom :itemdata="item" :page="page"></item-bottom></div>`,
|
||
});
|