记一个有关 Vuetify 组件遇到的一些问题

Vuetify 官网地址

所有Vuetify 组件 --- Vuetify

1、Combobox使用对象数组

Combobox 组合框 --- Vuetify

items数据使用对象数组时,默认选中的是整个对象,要对数据进行处理

TypeScript 复制代码
<v-combobox
  v-model="defaultInfo.variableKey"
  :rules="rules.variableKey"
  :placeholder="t('taskbot.flowBuilder.selectOrCreateVariable')"
  :items="variableList"
  item-title="fieldName"
  item-value="fieldName"
  variant="outlined"
  @update:focused="handleVariableList"
/>

variableList是一个对象数组,设置了item-value无效,需要在数据变化时实时取需要的字段值

TypeScript 复制代码
// v-combobox组件选择选项时会选择一个对象,对variableKey数据进行处理
watch(
  () => defaultInfo.value.variableKey,
  () => {
    if (Object.prototype.toString.call(defaultInfo.value.variableKey) === '[object Object]') {
      defaultInfo.value.variableKey = defaultInfo.value.variableKey['fieldName']
    }
  },
  {
    immediate: true
  }
)

2、Text fields的label带有提示文本

Text field 输入框 --- Vuetify

要实现下方文本框标题带有文字提示,鼠标浮动上时出现文本

添加一个" form-message-label "样式,主要是pointer-events:auto

html 复制代码
<div class="form-message-label">
  <v-text-field v-model="form.displayName" clearable>
    <template #label>
      <span>{{ t('taskbot.flowBuilder.displayName') }}</span>
      <Tooltip :title="t('tip.helpCenter.shortcuts')" />
    </template>
  </v-text-field>
</div>
css 复制代码
.form-message-label {
  .v-field__field {
    align-items: flex-start !important;
  }

  .v-field-label {
    width: auto !important;
    pointer-events: auto !important;
  }

  v-field__input {
    width: auto !important;
  }

  .v-field--active .v-label.v-field-label {
    width: 0 !important;
    padding: 0 !important;
    margin: 0 !important;
  }

  .v-label.v-field-label {
    position: relative !important;
    pointer-events: auto !important;
  }

  .v-field--active .v-label.v-field-label.v-field-label--floating {
    position: static !important;
    width: auto !important;
    padding: 5px !important;
    pointer-events: auto !important;
    transform: translateY(-50%);
    transform-origin: center;
  }
}

3、Select、Text fields、Combobox去掉边框线

相关推荐
啷咯哩咯啷几秒前
纯本地运行的私人文档知识库
前端·人工智能·后端
❆VE❆2 分钟前
基于 contenteditable 实现变量插入富文本编辑器
前端·javascript·vue.js
Aliex_git6 分钟前
Nuxt 学习笔记(一)
前端·笔记·学习
烤麻辣烫8 分钟前
json与fastjson
前端·javascript·学习·json
小陈同学呦16 分钟前
JavaScript 深浅拷贝详解
前端·javascript
六bring个六19 分钟前
opencv简单操作(一)
前端·webpack·node.js
小陈同学呦21 分钟前
fetch和axios区别
前端·javascript
森叶40 分钟前
Electron 实战:用 utilityProcess 开子进程,去端口化承载协议处理,并由主进程拦截渲染请求后统一中转
前端·javascript·electron
精益数智工坊1 小时前
红牌作战是什么?红牌作战的实施步骤与核心要点
大数据·运维·前端·人工智能·精益工程
techdashen1 小时前
Cloudflare HTML 解析器的十年演化史(一)
前端·html