2024-04-16

ant ui 抽屜 表單功能 --(頭部校驗可滾動到對應區(qū)域)——


<template>
  <a-drawer :open="visible" :title="title" @close="onClose">
    <a-form
      id="aaa_form"
      ref="formRef"
      :model="form"
      :rules="rules"
      :scroll-to-first-error="true"
    >
      <a-row :gutter="16">
        <a-col :span="24">
          <a-form-item label="Description" name="description">
            <a-textarea
              v-model:value="form.description"
              :rows="4"
              placeholder="Please enter url description"
            />
          </a-form-item>
        </a-col>
        <a-col :span="24">
          <a-form-item label="Description" name="description">
            <a-textarea
              v-model:value="form.description"
              :rows="4"
              placeholder="Please enter url description"
            />
          </a-form-item>
        </a-col>
        <a-col :span="24">
          <a-form-item label="Description" name="description">
            <a-textarea
              v-model:value="form.description"
              :rows="4"
              placeholder="Please enter url description"
            />
          </a-form-item>
        </a-col>
        <a-col :span="24">
          <a-form-item label="Description" name="description">
            <a-textarea
              v-model:value="form.description"
              :rows="4"
              placeholder="Please enter url description"
            />
          </a-form-item>
        </a-col>
        <a-col :span="24">
          <a-form-item label="Description" name="description">
            <a-textarea
              v-model:value="form.description"
              :rows="4"
              placeholder="Please enter url description"
            />
          </a-form-item>
        </a-col>
        <a-col :span="24">
          <a-form-item label="Description" name="description">
            <a-textarea
              v-model:value="form.description"
              :rows="4"
              placeholder="Please enter url description"
            />
          </a-form-item>
        </a-col>
        <a-col :span="24">
          <a-form-item label="Description" name="description">
            <a-textarea
              v-model:value="form.description"
              :rows="4"
              placeholder="Please enter url description"
            />
          </a-form-item>
        </a-col>
        <a-col :span="24">
          <a-form-item label="Description" name="description">
            <a-textarea
              v-model:value="form.description"
              :rows="4"
              placeholder="Please enter url description"
            />
          </a-form-item>
        </a-col>
        <a-col :span="24">
          <a-form-item label="Description" name="description">
            <a-textarea
              v-model:value="form.description"
              :rows="4"
              placeholder="Please enter url description"
            />
          </a-form-item>
        </a-col>
        <a-col :span="24">
          <a-form-item label="Description" name="description">
            <a-textarea
              v-model:value="form.description"
              :rows="4"
              placeholder="Please enter url description"
            />
          </a-form-item>
        </a-col>
        <a-col :span="24">
          <a-form-item label="Description" name="description">
            <a-textarea
              v-model:value="form.description"
              :rows="4"
              placeholder="Please enter url description"
            />
          </a-form-item>
        </a-col>
        <a-col :span="24">
          <a-form-item label="Description" name="description">
            <a-textarea
              v-model:value="form.description"
              :rows="4"
              placeholder="Please enter url description"
            />
          </a-form-item>
        </a-col>
        <a-col :span="24">
          <a-form-item label="Description" name="description">
            <a-textarea
              v-model:value="form.description"
              :rows="4"
              placeholder="Please enter url description"
            />
          </a-form-item>
        </a-col>
        <a-col :span="24">
          <a-form-item label="Description" name="description">
            <a-textarea
              v-model:value="form.description"
              :rows="4"
              placeholder="Please enter url description"
            />
          </a-form-item>
        </a-col>
        <a-col :span="24">
          <a-form-item label="Description" name="description">
            <a-textarea
              v-model:value="form.description"
              :rows="4"
              placeholder="Please enter url description"
            />
          </a-form-item>
        </a-col>
        <a-col :span="24">
          <a-form-item label="Description" name="description">
            <a-textarea
              v-model:value="form.description"
              :rows="4"
              placeholder="Please enter url description"
            />
          </a-form-item>
        </a-col>
        <a-col :span="24">
          <a-form-item label="Description" name="description">
            <a-textarea
              v-model:value="form.description"
              :rows="4"
              placeholder="Please enter url description"
            />
          </a-form-item>
        </a-col>
        <a-col :span="24">
          <a-form-item label="Description" name="description">
            <a-textarea
              v-model:value="form.description"
              :rows="4"
              placeholder="Please enter url description"
            />
          </a-form-item>
        </a-col>
        <a-col :span="24">
          <a-form-item label="Description" name="description">
            <a-textarea
              v-model:value="form.description"
              :rows="4"
              placeholder="Please enter url description"
            />
          </a-form-item>
        </a-col>
        <a-col :span="24">
          <a-form-item label="Description" name="description">
            <a-textarea
              v-model:value="form.description"
              :rows="4"
              placeholder="Please enter url description"
            />
          </a-form-item>
        </a-col>
      </a-row>
      <a-space>
        <a-button @click="onClose">Cancel</a-button>
        <a-button type="primary" @click="onSubmit" html-type="submit"
          >Submit</a-button
        >
      </a-space>
    </a-form>
    <template #extra>
      <a-space>
        <a-button @click="onClose">Cancel</a-button>
        <a-button
          type="primary"
          form="aaa_form"
          @click="onSubmit"
          html-type="submit"
          >Submit</a-button
        >
      </a-space>
    </template>
  </a-drawer>
</template>
<script setup>
import { ref } from "vue";

const visible = ref(true);
const title = "Drawer Title";
const form = ref({
  description: "",
});
const formRef = ref(null);

const rules = {
  description: [
    {
      required: true,
      message: "Please enter the description",
      trigger: "blur",
    },
  ],
};

function onClose() {
  visible.value = false;
}

async function onSubmit() {
  try {
    await formRef.value.validate();
    console.log("Form values:", form.value);

    onClose(); // Close the drawer after successful submission
  } catch (error) {
    console.error("Error:", error);
  }
}

</script>

最后編輯于
?著作權歸作者所有,轉載或內容合作請聯(lián)系作者
  • 序言:七十年代末,一起剝皮案震驚了整個濱河市颖杏,隨后出現(xiàn)的幾起案子,更是在濱河造成了極大的恐慌,老刑警劉巖兴垦,帶你破解...
    沈念sama閱讀 222,183評論 6 516
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件嗅定,死亡現(xiàn)場離奇詭異腺毫,居然都是意外死亡,警方通過查閱死者的電腦和手機摸袁,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 94,850評論 3 399
  • 文/潘曉璐 我一進店門,熙熙樓的掌柜王于貴愁眉苦臉地迎上來义屏,“玉大人靠汁,你說我怎么就攤上這事∶鲱恚” “怎么了蝶怔?”我有些...
    開封第一講書人閱讀 168,766評論 0 361
  • 文/不壞的土叔 我叫張陵,是天一觀的道長阳啥。 經常有香客問我添谊,道長,這世上最難降的妖魔是什么察迟? 我笑而不...
    開封第一講書人閱讀 59,854評論 1 299
  • 正文 為了忘掉前任斩狱,我火速辦了婚禮耳高,結果婚禮上,老公的妹妹穿的比我還像新娘所踊。我一直安慰自己泌枪,他們只是感情好,可當我...
    茶點故事閱讀 68,871評論 6 398
  • 文/花漫 我一把揭開白布秕岛。 她就那樣靜靜地躺著碌燕,像睡著了一般。 火紅的嫁衣襯著肌膚如雪继薛。 梳的紋絲不亂的頭發(fā)上修壕,一...
    開封第一講書人閱讀 52,457評論 1 311
  • 那天,我揣著相機與錄音遏考,去河邊找鬼慈鸠。 笑死,一個胖子當著我的面吹牛灌具,可吹牛的內容都是我干的青团。 我是一名探鬼主播,決...
    沈念sama閱讀 40,999評論 3 422
  • 文/蒼蘭香墨 我猛地睜開眼咖楣,長吁一口氣:“原來是場噩夢啊……” “哼督笆!你這毒婦竟也來了?” 一聲冷哼從身側響起诱贿,我...
    開封第一講書人閱讀 39,914評論 0 277
  • 序言:老撾萬榮一對情侶失蹤娃肿,失蹤者是張志新(化名)和其女友劉穎,沒想到半個月后瘪松,有當地人在樹林里發(fā)現(xiàn)了一具尸體咸作,經...
    沈念sama閱讀 46,465評論 1 319
  • 正文 獨居荒郊野嶺守林人離奇死亡,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內容為張勛視角 年9月15日...
    茶點故事閱讀 38,543評論 3 342
  • 正文 我和宋清朗相戀三年宵睦,在試婚紗的時候發(fā)現(xiàn)自己被綠了记罚。 大學時的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片。...
    茶點故事閱讀 40,675評論 1 353
  • 序言:一個原本活蹦亂跳的男人離奇死亡壳嚎,死狀恐怖桐智,靈堂內的尸體忽然破棺而出,到底是詐尸還是另有隱情烟馅,我是刑警寧澤说庭,帶...
    沈念sama閱讀 36,354評論 5 351
  • 正文 年R本政府宣布,位于F島的核電站郑趁,受9級特大地震影響刊驴,放射性物質發(fā)生泄漏。R本人自食惡果不足惜,卻給世界環(huán)境...
    茶點故事閱讀 42,029評論 3 335
  • 文/蒙蒙 一捆憎、第九天 我趴在偏房一處隱蔽的房頂上張望舅柜。 院中可真熱鬧,春花似錦躲惰、人聲如沸致份。這莊子的主人今日做“春日...
    開封第一講書人閱讀 32,514評論 0 25
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽氮块。三九已至,卻和暖如春诡宗,著一層夾襖步出監(jiān)牢的瞬間滔蝉,已是汗流浹背。 一陣腳步聲響...
    開封第一講書人閱讀 33,616評論 1 274
  • 我被黑心中介騙來泰國打工僚焦, 沒想到剛下飛機就差點兒被人妖公主榨干…… 1. 我叫王不留锰提,地道東北人曙痘。 一個月前我還...
    沈念sama閱讀 49,091評論 3 378
  • 正文 我出身青樓芳悲,卻偏偏與公主長得像,于是被迫代替她去往敵國和親边坤。 傳聞我的和親對象是個殘疾皇子名扛,可洞房花燭夜當晚...
    茶點故事閱讀 45,685評論 2 360

推薦閱讀更多精彩內容

  • 用兩張圖告訴你,為什么你的 App 會卡頓? - Android - 掘金 Cover 有什么料茧痒? 從這篇文章中你...
    hw1212閱讀 12,745評論 2 59
  • 技術棧 目標:了解開發(fā)本項目所要使用的各類框架肮韧、庫 腳手架工具:create-react-app 組件編寫方式: ...
    fengqi閱讀 3,334評論 0 0
  • 發(fā)現(xiàn) 關注 消息 iOS 第三方庫、插件旺订、知名博客總結 作者大灰狼的小綿羊哥哥關注 2017.06.26 09:4...
    肇東周閱讀 12,121評論 4 61
  • 徽標/標簽/Badge[https://mobile.ant.design/components/badge-cn...
    dddt01閱讀 1,427評論 1 13
  • 嗯哼嗯哼蹦擦擦~~~ 轉載自:https://github.com/Tim9Liu9/TimLiu-iOS 目錄 ...
    philiha閱讀 4,910評論 0 6