Files
PC-Light-Forum/component/hot-search/hot-search.js
A1300399510 a7d803f633 no message
2025-11-04 01:57:07 +08:00

30 lines
1015 B
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// my-component.js
// 引入全局 Vue 对象(因在 HTML 中通过 script 引入Vue 已挂载到 window
const { defineComponent, ref, onMounted } = Vue;
// 定义组件(直接使用模板)
export const hotSearch = defineComponent({
name: "hot-search",
props: {},
setup(props) {
onMounted(() => {
init();
});
const init = () => {
ajaxGet("/v2/api/forum/getHotSearchWords?limit=20").then((res) => {
const data = res.data;
list.value = data || [];
});
};
const list = ref([]);
return { list };
},
components: {},
template: `<div class="hot-tag" v-if="list.length > 0"> <div class="hot-tag-title"> <img class="icon" src="/img/triangle-violet.svg" /> 热门搜索 </div> <div class="list flexflex"> <a class="item" v-for="item in list" :href="'/search/' + item.keyword" target="_blank">{{ item.keyword }}</a> </div></div>`,
});