记一个有关 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去掉边框线

相关推荐
阿蒙Amon16 分钟前
JavaScript学习笔记:6.表达式和运算符
javascript·笔记·学习
hashiqimiya38 分钟前
两个步骤,打包war,tomcat使用war包
java·服务器·前端
小a杰.1 小时前
Flutter 设计系统构建指南
开发语言·javascript·ecmascript
零度@1 小时前
Java中Map的多种用法
java·前端·python
yuanyxh2 小时前
静默打印程序实现
前端·react.js·electron
三十_A3 小时前
如何正确实现圆角渐变边框?为什么 border-radius 对 border-image 不生效?
前端·css·css3
kgduu3 小时前
js之事件系统
javascript
小满zs3 小时前
Next.js第十三章(缓存组件)
前端
前端老宋Running3 小时前
“受控组件”的诅咒:为什么你需要 React Hook Form + Zod 来拯救你的键盘?
前端·javascript·react.js
风止何安啊3 小时前
拿捏 React 组件通讯:从父子到跨组件的「传功秘籍」
前端·react.js·面试