若依框架 新增外键表单组件

外键表单组件

若依框架提供了下拉框组件,但是数据是枚举数据中读取,但是对于外键表单没有提供。定义一个TableTag

html 复制代码
<template>
  <div>
    <template v-for="(item, index) in options" >
      <template >
        <span

          v-if="value==item.id"
        >{{ item[label] }}</span
        >

      </template>
    </template>
  </div>
</template>

<script>
export default {
  name: "TableTag",
  props: {
    options: {
      type: Array,
      default: null,
    },
    value: [Number, String, Array],
    label: {
      type: String,
      default: "displayName",
    },
  },
  computed: {
    values() {
      console.log(Array.isArray(this.value) ? this.value : [String(this.value)])
      if (this.value !== null && typeof this.value !== 'undefined') {
        return Array.isArray(this.value) ? this.value : [String(this.value)];
      } else {
        return [];
      }
    },
  },
};
</script>
<style scoped>
.el-tag + .el-tag {
  margin-left: 10px;
}
</style>

main.js中

javascript 复制代码
import TableTag from "@/components/TableTag";
Vue.component('TableTag',TableTag)
相关推荐
zhensherlock2 小时前
Protocol Launcher 系列:Working Copy 文件操作与高级命令详解
javascript·git·typescript·node.js·自动化·github·js
神の愛8 小时前
左连接查询数据 left join
java·服务器·前端
小码哥_常9 小时前
解锁Android嵌入式照片选择器,让你的App体验丝滑起飞
前端
郑寿昌10 小时前
IIoT本体迁移的领域扩展机制
服务器·前端·microsoft
深海鱼在掘金10 小时前
Next.js从入门到实战保姆级教程(第十一章):错误处理与加载状态
前端·typescript·next.js
深海鱼在掘金11 小时前
Next.js从入门到实战保姆级教程(第十二章):认证鉴权与中间件
前端·typescript·next.js
energy_DT11 小时前
2026年十五五油气田智能增产装备数字孪生,CIMPro孪大师赋能“流动增产工厂”三维可视化管控
前端
龙猫里的小梅啊11 小时前
CSS(四)CSS文本属性
前端·css
MXN_小南学前端11 小时前
watch详解:与computed 对比以及 Vue2 / Vue3 区别
前端·javascript·vue.js
饭小猿人11 小时前
Flutter实现底部动画弹窗有两种方式
开发语言·前端·flutter