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

外键表单组件

若依框架提供了下拉框组件,但是数据是枚举数据中读取,但是对于外键表单没有提供。定义一个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)
相关推荐
万少4 小时前
小龙虾(openclaw),轻松玩转自动发帖
前端·人工智能·后端
Jagger_5 小时前
抱怨到躺床关灯的一次 DIY 记录
前端
陈随易8 小时前
前端大咖mizchi不满Rust、TypeScript却爱上MoonBit
前端·后端·程序员
whinc10 小时前
🚀 两年小程序开发,我把踩过的坑做成了开源 Skills
前端·微信小程序·ai编程
兆子龙11 小时前
ahooks useRequest 深度解析:一个 Hook 搞定所有请求
java·javascript
兆子龙11 小时前
React Suspense 从入门到实战:让异步加载更优雅
java·javascript
sure28211 小时前
React Native中创建自定义渐变色
前端·react native
KKKK11 小时前
SSE(Server-Sent Events)流式传输原理和XStream实践
前端·javascript
子兮曰12 小时前
Humanizer-zh 实战:把 AI 初稿改成“能发布”的技术文章
前端·javascript·后端