import html from "html";
import { defineAsyncComponent, reactive, watch } from "vue";
import { useRouter } from "vue-router";
export default {
name: "menuItem",
components: { SvgIcon: defineAsyncComponent(() => import("../components/icon/index.js")) },
template: html`
{{modelValue.meta.title}}
{{modelValue.meta.title}}
`,
props: {
modelValue: {
typeof: Object,
},
},
setup(props, context) {
const router = useRouter();
const model = reactive(props.modelValue);
watch(
model,
(value) => {
context.emit("update:modelValue", value);
},
{ deep: true }
);
//
const click = (route) => {
if (!route.meta.isExternal) {
router.push(route.meta.path);
} else {
window.open(route.path);
}
};
//
return {
model,
click,
};
},
};