import html from "html";
import { reactive, watch } from "vue";
import Icon from "../components/icon/index.js";
import { useRouter } from "vue-router";
export default {
name: "menuItem",
components: { Icon },
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,
};
},
};