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

外键表单组件

若依框架提供了下拉框组件,但是数据是枚举数据中读取,但是对于外键表单没有提供。定义一个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)
相关推荐
xuco5 分钟前
如何让流式输出的 Markdown 渲染更丝滑
前端·agent
Pu_Nine_95 分钟前
Vue3 + ECharts 企业级封装实践:按需引入 + useECharts Hooks
前端·vue.js·echarts
问心无愧05136 分钟前
ctf show web入门91
android·前端·笔记
YAwu118 分钟前
JavaScript 作用域与执行机制深度解析
前端·javascript
暗不需求8 分钟前
深入理解 React 受控组件与非受控组件:从源码到面试
前端·react.js·面试
Yue1689 分钟前
天津理工大学前端组大一末期考核随记(2)
前端·javascript
冰凌时空9 分钟前
Swift 类型系统入门:从 Int、String 到自定义类型
前端·ios·ai编程
hexu_blog13 分钟前
前端vue后端java+springboot如何实现pdf,word,excel之间的相互转换
java·前端·vue.js·spring boot·文档转换
w_t_y_y43 分钟前
vue父子组件通信(二)祖先调用inject
前端·javascript·vue.js
哆哆啦0044 分钟前
URL 重写规则和静态资源解析逻辑
前端·浏览器·url