// 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)); // 定义组件(直接使用模板) export const itemSummary = defineComponent({ name: "item-summary", props: { itemdata: { type: Object, default: () => {}, }, page: { type: String, default: "", }, }, setup(props) { let item = ref({ ...props.itemdata }); 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: `
{{ item.title }} {{ item.content }}
{{ item.data.offercount }}
个Offer
查看更多
`, });