48 lines
2.3 KiB
JavaScript
48 lines
2.3 KiB
JavaScript
// my-component.js
|
||
// 引入全局 Vue 对象(因在 HTML 中通过 script 引入,Vue 已挂载到 window)
|
||
const { defineComponent, ref, defineAsyncComponent } = Vue;
|
||
const itemBottom = defineAsyncComponent(() => import(withVer("../item-bottom/item-bottom.js")).then((m) => m.itemBottom));
|
||
const itemHead = defineAsyncComponent(() => import(withVer("../item-head/item-head.js")).then((m) => m.itemHead));
|
||
|
||
// const { itemBottom } = await import(withVer("../item-bottom/item-bottom.js"));
|
||
// const { itemHead } = await import(withVer("../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;
|
||
|
||
let valueUrl = ref("");
|
||
const valueA = document.querySelector(".valueA");
|
||
valueUrl.value = valueA.innerText;
|
||
|
||
return { valueUrl, 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> <a class="picture flexacenter" :href="item.url" target="_blank" v-if="item.images?.length != 0 || item.videos?.length != 0"> <img class="picture-item" v-for="(item, index) in item.images" :key="index" :src="item.url" alt=""> <template v-for="(item, index) in item.videos" :key="index"> <div v-if="item.posterurl" class="picture-videos flexacenter"> <img class="picture-item" :src="item.posterurl" alt=""> <img class="icon-play" :src="valueUrl + '/img/videoplay.png'" alt=""> </div> </template> </a> <item-bottom :itemdata="item" :page="page"></item-bottom></div>`,
|
||
});
|