You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
40 lines
1.1 KiB
40 lines
1.1 KiB
|
3 years ago
|
import { defineComponent, PropType } from "vue-demi";
|
||
|
|
import { h } from "../../../utils";
|
||
|
|
import "../styles/search-suggests.scss";
|
||
|
|
|
||
|
|
export const SearchSuggests = defineComponent({
|
||
|
|
props: {
|
||
|
|
/** 搜索建议数组 */
|
||
|
|
suggests: { type: Array as PropType<T.LocalSearchSuggest[]>, default: () => [] }
|
||
|
|
},
|
||
|
|
emits: {
|
||
|
|
/** 点击搜索建议项 */
|
||
|
|
"suggest-click": (e: T.LocalSearchSuggest) => true
|
||
|
|
},
|
||
|
|
setup(props, { emit }) {
|
||
|
|
return () =>
|
||
|
|
h(
|
||
|
|
"div",
|
||
|
|
{
|
||
|
|
class: "tdt-search-suggests",
|
||
|
|
style: { display: props.suggests.length ? "block" : "none" }
|
||
|
|
},
|
||
|
|
props.suggests.map(item => {
|
||
|
|
return h(
|
||
|
|
"div",
|
||
|
|
{
|
||
|
|
class: "search-suggests-item",
|
||
|
|
on: {
|
||
|
|
click: () => emit("suggest-click", item)
|
||
|
|
}
|
||
|
|
},
|
||
|
|
[
|
||
|
|
h("span", { class: "search-suggests-item__name" }, item.name),
|
||
|
|
h("span", { class: "search-suggests-item__address" }, item.address)
|
||
|
|
]
|
||
|
|
);
|
||
|
|
})
|
||
|
|
);
|
||
|
|
}
|
||
|
|
});
|