const base = { template: `
搜索项目
项目对比
{{ count }}
`, data() { return { hideIcon: false, top: 0, left: 0, count: 0, } }, methods: { customMethod() { console.log("Custom method called") }, // 计算按钮位置 calculate(random, count) { this.count = count const dom = document.querySelector(".add" + random) if (!dom) return const rect = dom.getBoundingClientRect() const top = rect.top + rect.height / 2 - 5 const left = rect.left + rect.width / 2 - 5 this.top = top this.left = left this.hideIcon = true setTimeout(() => { const dom = document.querySelector(".base .number") const rect = dom.getBoundingClientRect() const top = rect.top + rect.height / 2 - 5 const left = rect.left + rect.width / 2 - 5 this.top = top this.left = left }, 10) setTimeout(() => { this.top = null this.left = null this.hideIcon = false }, 330) }, }, } const textModule = { template: `
{{ text }}
{{ title }}
{{ text }}
{{ text }}
{{ current }}/{{ page.length }}
`, props: ["text", "title"], setup(props) { console.log(props.text) // let text = ref(`55`) const textRef = ref(null) let page = ref(0) let h = ref(0) let isswiper = ref(false) onMounted(() => { console.log("props", props) if (props.text.length < 20) return const lineHeight = 32 const height = lineHeight * 10 const pagecount = textRef.value.clientHeight / height let arr = [] for (let i = 0; i < Math.floor(pagecount); i++) { arr.push(height) } const decimalPart = parseFloat("0." + pagecount.toString().split(".")[1]) if (decimalPart > 0) arr.push(height * decimalPart) page.value = arr h.value = height isswiper.value = arr.length > 1 ? true : false }) const listRef = ref(null) let current = ref(1) const cutHotListPage = type => { if (type == "left") { if (current.value > 1) current.value-- } else { if (current.value < page.value.length) current.value++ } listRef.value.scrollTo({ left: 640 * (current.value - 1), behavior: "smooth", }) } // 计算 const reversedMessage = type => { if (type == "left") { if (current.value == 1) return "/img/arrows-triangle-gray.svg" else return "/img/arrows-triangle-red.png" } else { if (current.value == page.value.length) return "/img/arrows-triangle-gray.svg" else return "/img/arrows-triangle-red.png" } } return { reversedMessage, cutHotListPage, textRef, isswiper, h, page, current, listRef } }, }