refactor(component): 重构组件模板结构,移除重复代码 feat(component): 添加可选props支持外部数据传入 style(css): 优化样式布局和响应式设计 fix(js): 修复URL路径处理逻辑和滚动加载问题 feat(search): 新增搜索页推荐内容和空状态处理 chore: 添加新图标资源文件
37 lines
2.3 KiB
JavaScript
37 lines
2.3 KiB
JavaScript
// my-component.js
|
||
// 引入全局 Vue 对象(因在 HTML 中通过 script 引入,Vue 已挂载到 window)
|
||
const { defineComponent, ref, defineAsyncComponent } = Vue;
|
||
|
||
// const { itemBottom } = await import(withVer("../item-bottom/item-bottom.js"));
|
||
// const { itemHead } = await import(withVer("../item-head/item-head.js"));
|
||
const itemHead = defineAsyncComponent(() => import(withVer("../item-head/item-head.js")).then((m) => m.itemHead));
|
||
const itemBottom = defineAsyncComponent(() => import(withVer("../item-bottom/item-bottom.js")).then((m) => m.itemBottom));
|
||
|
||
// 定义组件(直接使用模板)
|
||
export const itemMj = defineComponent({
|
||
name: "item-mj",
|
||
props: {
|
||
itemdata: {
|
||
type: Object,
|
||
default: () => {},
|
||
},
|
||
page: {
|
||
type: String,
|
||
default: "",
|
||
},
|
||
},
|
||
|
||
setup(props) {
|
||
let item = ref({ ...props.itemdata });
|
||
item.value["url"] = "/details/" + item.value.uniqid;
|
||
return { item };
|
||
},
|
||
|
||
components: {
|
||
itemBottom,
|
||
itemHead,
|
||
},
|
||
|
||
template: `<div class="item-box item-mj"> <item-head :itemdata="item" :page="page"></item-head> <a class="school flexacenter" :href="item.url" target="_blank" v-if="item.data.schoolname"> <img class="icon" v-if="item.data.schoollogo" :src="item.data.schoollogo" /> <div class="text flex1 one-line-display">{{ item.data.schoolname }}</div> </a> <a class="major flexacenter" v-if="item.data.professional" :href="item.url" target="_blank"> <div class="key">{{ item.data.project ? '专业' : '项目/专业' }}</div> <div class="value flex1 one-line-display">{{ item.data.professional }}</div> </a> <a class="major flexacenter" v-if="item.data.project" :href="item.url" target="_blank"> <div class="key">项目</div> <div class="value flex1 one-line-display">{{ item.data.project }}</div> </a> <a class="major flexacenter" v-if="item.data.interviewtime" :href="item.url" target="_blank"> <div class="key">面试</div> <div class="value time flex1 one-line-display">{{ item.data.interviewtime }}</div> </a> <a class="message" v-if="item.content" :href="item.url" target="_blank">{{ item.content }}</a> <item-bottom :itemdata="item" :page="page"></item-bottom></div>`,
|
||
});
|