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

相关推荐
OpenTiny社区5 小时前
WebMCP + WebSkills:企业级智能化页面操控方案,兼顾隐私安全与高效落地!
前端·ai编程·mcp
酉鬼女又兒5 小时前
零基础快速入门前端JavaScript四大核心内置对象:Math、Date、String、Array全解析(可用于备赛蓝桥杯Web应用开发)
前端·javascript·css·蓝桥杯·前端框架·js
__sgf__5 小时前
ES11(ES2020)新特性
前端·javascript
__sgf__6 小时前
ES8(ES2017)新特性
前端·javascript
__sgf__6 小时前
ES9(ES2018)新特性
前端·javascript
送鱼的老默6 小时前
学习笔记--vue3 watchEffect监听的各种姿势用法和总结
前端·vue.js
你挚爱的强哥6 小时前
解决:动态文本和背景色一致导致文字看不清楚,用js获取背景图片主色调,并获取对比度最大的hex色值给文字
前端·javascript·github
英俊潇洒美少年6 小时前
js 同步异步,宏任务微任务的关系
开发语言·javascript·ecmascript
用户69371750013846 小时前
Android 手机终于能当电脑用了
android·前端
wooyoo6 小时前
花了一周 vibe 了一个 OpenClaw 的 Agent 市场,聊聊过程中踩的坑
前端·后端·agent