vue3 动态组件

动态组件


          
        

在页面中引入组件

import PosCom from "../components/Position/PosCom.vue";
import PullCom from "../components/Position/PullCom.vue";

import { reactive } from "vue";
import { markRaw } from "vue";

const data = reactive([
  {
    name: "招聘中",
    comName: markRaw(PosCom),
  },
  {
    name: "已下架",
    comName: markRaw(PullCom),
  },
]);

// 设置默认选中
let current = reactive({
  comName: data[0].comName,
});

const selectactive = (item) => {
  current.comName = item.comName;
};

你可能感兴趣的:(前端,javascript,html)