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

外键表单组件

若依框架提供了下拉框组件,但是数据是枚举数据中读取,但是对于外键表单没有提供。定义一个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)
相关推荐
yinuo1 小时前
前端跨页面通讯终极指南⑥:SharedWorker 用法全解析
前端
PineappleCoder6 小时前
还在重复下载资源?HTTP 缓存让二次访问 “零请求”,用户体验翻倍
前端·性能优化
拉不动的猪6 小时前
webpack编译中为什么不建议load替换ast中节点删除consolg.log
前端·javascript·webpack
李姆斯6 小时前
Agent时代下,ToB前端的UI和交互会往哪走?
前端·agent·交互设计
源码获取_wx:Fegn08956 小时前
基于springboot + vue健身房管理系统
java·开发语言·前端·vue.js·spring boot·后端·spring
闲谈共视7 小时前
基于去中心化社交与AI智能服务的Web钱包商业开发的可行性
前端·人工智能·去中心化·区块链
CreasyChan7 小时前
C# 反射详解
开发语言·前端·windows·unity·c#·游戏开发
JIngJaneIL7 小时前
基于Java+ vue智慧医药系统(源码+数据库+文档)
java·开发语言·前端·数据库·vue.js·spring boot
+VX:Fegn08957 小时前
计算机毕业设计|基于springboot + vue图书管理系统(源码+数据库+文档)
数据库·vue.js·spring boot·后端·课程设计
阿蒙Amon8 小时前
JavaScript学习笔记:6.表达式和运算符
javascript·笔记·学习