// 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 itemVote = defineComponent({ name: "item-vote", props: { itemdata: { type: Object, default: () => {}, }, }, setup(props) { let item = ref({ ...props.itemdata }); item.value['url'] = 'https://vote.gter.net/details/' + item.value.uniqid; return { item }; }, components: { itemBottom, itemHead, }, template: `
{{ item.title }} {{ item.content }}
已结束
{{ item?.data?.votes }}
人参与
{{ index + 1 }}
{{ item.value }}
{{ item.count }}
`, });