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

相关推荐
TE-茶叶蛋4 分钟前
HTML5 更新的功能
前端·html·html5
巴别塔的饿灵15 分钟前
事件循环机制
前端
用户527096487449020 分钟前
快速过一遍 ts
前端
yrjw22 分钟前
最新发布的一款使用ReactNative新架构支持加载的Svga动画开源插件
前端
南方kenny25 分钟前
用HTML+CSS+JS复刻了水果忍者——Vibe Coding活动摸鱼实录
前端·aigc·vibecoding
&白帝&30 分钟前
vue中常用的api($set,$delete,$nextTick..)
前端·javascript·vue.js
要加油哦~34 分钟前
vue | async-validator 表单验证库 第三方库安装与使用
前端·javascript·vue.js
阿酷tony1 小时前
视频点播web端AI智能大纲(自动生成视频内容大纲)的代码与演示
前端·人工智能·视频ai·视频智能大纲·ai智能大纲
小李小李不讲道理1 小时前
「Ant Design 组件库探索」三:Select组件
前端·javascript·react.js
二闹1 小时前
TypeScript核心玩法,顺便附赠面试通关秘籍!
前端·typescript