最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

vue實(shí)現(xiàn)表單驗(yàn)證小功能

 更新時(shí)間:2021年09月29日 09:55:21   作者:郁郁青枝  
這篇文章主要為大家詳細(xì)介紹了vue實(shí)現(xiàn)表單驗(yàn)證小功能,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下

本文實(shí)例為大家分享了vue實(shí)現(xiàn)表單驗(yàn)證的具體代碼,供大家參考,具體內(nèi)容如下

1.路由跳轉(zhuǎn)

先點(diǎn)開Vue項(xiàng)目中src目錄配置router文件然后用import暴露你的表單頁(yè)名稱并在你的Router實(shí)例中中注冊(cè)路由表代碼如下

import Create from "@/views/create/create.vue";

//前面是暴露的名字,首字母要用大寫。后面是你的表單頁(yè)所在目錄@是..的簡(jiǎn)寫即返回上一層


const router=new Router({
mode:"history"http://這里是寫路由是什么模式
routes:[
{
      path: "/create",//默認(rèn)為/多個(gè)的話就是/加上路徑
      name: "create",
      component: Create,
      title: "表單",
    },
]
})

路由表配置完成之后記得將home頁(yè)中的自己router-link標(biāo)簽的to選項(xiàng)配置一下

<router-link :to="{ name: 'create' }" class="collection">表單</router-link>

隨后就是表單頁(yè)

效果圖

 

功能實(shí)現(xiàn)代碼如下

插件用的是element.ui可以在終端中使用npm i element-ui 安裝成功之后在package.json中查看并在main.js中引用

 

 

 

安裝完成后就可以使用啦。

<template>
  <div class="create">
    <h2>歡迎發(fā)布新菜譜,先介紹一下你的大作!</h2>
    <section class="create-introduce">
      <h5>標(biāo)題</h5>
 
      <el-input
        v-model="backData.title"
        class="create-input"
        placeholder="請(qǐng)輸入內(nèi)容"
      ></el-input>
      <h5>屬性</h5>
      <div>
        <el-select
          v-for="item in propertyies"
          :key="item.parent_name"
          :placeholder="item.parent_name"
          v-model="backData.property[item.title]"
        >
          <el-option
            v-for="option in item.list"
            :key="option.type"
            :label="option.name"
            :value="option.type"
          >
          </el-option>
        </el-select>
      </div>
      <h5>菜譜分類</h5>
      <div>
        <el-select placeholder="請(qǐng)選擇菜譜分類" v-model="backData.classify">
          <el-option-group
            v-for="group in classifies"
            :key="group.parent_type"
            :label="group.parent_name"
          >
            <el-option
              v-for="item in group.list"
              :key="item.type"
              :label="item.name"
              :value="item.type"
            >
            </el-option>
          </el-option-group>
        </el-select>
      </div>
      <h5>成品圖 (328*440)</h5>
      <div class="upload-img-box clearfix">
        <div class="upload-img">
          <upload-img
            action="/api/upload?type=product"
            :img-url="backData.product_pic_url"
            @res-url="
              (data) => {
                backData, (product_pic_url = data.res);
              }
            "
          ></upload-img>
        </div>
        <el-input
          class="introduce-text"
          type="textarea"
          :rows="10"
          placeholder="請(qǐng)輸入內(nèi)容"
        >
        </el-input>
      </div>
    </section>
 
    <h2>記錄所有原材料</h2>
    <section class="create-introduce">
      <h5>主料</h5>
      <!--[ { "name": "", "specs": "" }, { "name": "", "specs": "" }, { "name": "", "specs": "" } ]-->
      <Stuff v-model="backData.raw_material.main_material"></Stuff>
      <h5>輔料</h5>
      <Stuff v-model="backData.raw_material.accessories_material"></Stuff>
    </section>
 
    <h2>開始寫步驟了!能否簡(jiǎn)單易學(xué)就看你怎么寫了,加油!</h2>
    <section class="create-introduce">
      <Upload v-for="(item, index) in 3" :key="index"></Upload>
      <el-button
        class="eaeaea add-step-button"
        type="primary"
        size="medium"
        icon="el-icon-plus"
        @click="add"
        >增加一步</el-button
      >
      <h5>烹飪小技巧</h5>
      <el-input
        class="introduce-text"
        type="textarea"
        :rows="8"
        placeholder="分享下你做這道菜的過(guò)程中的心得和小技巧吧!"
      >
      </el-input>
    </section>
 
    <el-button class="send" type="primary" size="medium" :icon="icon"
      >搞定,提交審核</el-button
    >
  </div>
</template>
<script>
import Stuff from "./stuff";
import Upload from "./step-upload";
import UploadImg from "@/components/upload-img";
import { getProperty, getClassify, publish } from "@/service/api";
 
const raw_materia_struct = {
  name: "",
  specs: "",
};
export default {
  name: "create",
  components: { Stuff, Upload, UploadImg },
  data() {
    return {
      backData: {
        title: "",
        property: {},
        classify: "",
        product_pic_url: "",
        product_story: "",
        raw_material: {
          raw_material: Array(3)
            .fill(1)
            .map(() => ({ ...raw_materia_struct })),
          accessories_material: Array(3)
            .fill(1)
            .map(() => ({ ...raw_materia_struct })),
        },
      },
      propertyies: [],
      classifies: [],
    };
  },
  mounted() {
    getProperty().then(({ data }) => {
      console.log(data);
      this.propertyies = data;
      this.backData.property = data.reduce((o, item) => {
        o[item.title] = "";
        return o;
      }, {});
      //  console.log(data);
      //  console.log(this.backData.property)
    });
    getClassify().then(({ data }) => {
      console.log(data);
      this.classifies = data;
    });
  },
  methods: {
    add() {
      console.log(1);
    },
  },
};
</script>
<style lang="stylus">
 
 
.create-introduce
  background-color #fff
  padding 20px
 
 
  .add-step-button
    margin-left 100px
 
 
.create
  width 100%
  h2
    text-align center
    margin 20px 0
  .send
    // ff3232()
    height: 70px;
    width: 220px;
    background #ff3232
    color #fff
    border none
    margin 20px auto
    display block
 
  h5
    margin 20px 0
 
 
.create-input input
  width 446px
  line-height 22px
.upload-img-box
  .upload-img
    float left
  .introduce-text
    float left
  .el-textarea
    width 60%
    margin-left 10px
</style>

以上就是vue表單的全部?jī)?nèi)容。

以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

  • Vue應(yīng)用部署到服務(wù)器的正確方式

    Vue應(yīng)用部署到服務(wù)器的正確方式

    本篇文章主要介紹了詳解Vue應(yīng)用部署到服務(wù)器的正確方式,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下。
    2017-07-07
  • Vue設(shè)置別名聯(lián)想路徑即@/生效的方法

    Vue設(shè)置別名聯(lián)想路徑即@/生效的方法

    這篇文章主要給大家介紹了Vue設(shè)置別名聯(lián)想路徑即@/生效的方法,文中有詳細(xì)的代碼示例和圖文講解,具有一定的參考價(jià)值,需要的朋友可以參考下
    2023-11-11
  • element?ui動(dòng)態(tài)側(cè)邊菜單欄及頁(yè)面布局實(shí)現(xiàn)方法

    element?ui動(dòng)態(tài)側(cè)邊菜單欄及頁(yè)面布局實(shí)現(xiàn)方法

    后臺(tái)管理系統(tǒng)經(jīng)常會(huì)使用到一個(gè)左側(cè)菜單欄,右側(cè)Tab頁(yè)的頁(yè)面顯示結(jié)構(gòu),這篇文章主要給大家介紹了關(guān)于element?ui動(dòng)態(tài)側(cè)邊菜單欄及頁(yè)面布局實(shí)現(xiàn)的相關(guān)資料,需要的朋友可以參考下
    2023-09-09
  • vue圖片壓縮與批量上傳方式

    vue圖片壓縮與批量上傳方式

    文章介紹了使用Vue和Element UI的el-upload組件實(shí)現(xiàn)圖片的批量上傳和壓縮功能,前端需引入image-conversion庫(kù)并設(shè)置相關(guān)屬性,關(guān)閉自動(dòng)上傳,通過(guò)on-change事件校驗(yàn)文件名和大小,并增加一個(gè)提交到服務(wù)器的按鈕
    2025-01-01
  • vue 動(dòng)態(tài)創(chuàng)建組件的兩種方法

    vue 動(dòng)態(tài)創(chuàng)建組件的兩種方法

    這篇文章主要介紹了vue 動(dòng)態(tài)創(chuàng)建組件的兩種方法,幫助大家更好的理解和使用vue框架,感興趣的朋友可以了解下
    2020-12-12
  • Vue+Element-ui表單resetFields無(wú)法重置問(wèn)題

    Vue+Element-ui表單resetFields無(wú)法重置問(wèn)題

    本文主要介紹了Vue+Element-ui表單resetFields無(wú)法重置問(wèn)題,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧
    2022-04-04
  • vue實(shí)現(xiàn)移動(dòng)端拖動(dòng)排序

    vue實(shí)現(xiàn)移動(dòng)端拖動(dòng)排序

    這篇文章主要為大家詳細(xì)介紹了vue實(shí)現(xiàn)移動(dòng)端拖動(dòng)排序,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2020-08-08
  • Vue中mixins混入的介紹與使用詳解

    Vue中mixins混入的介紹與使用詳解

    如果我們?cè)诿總€(gè)組件中去重復(fù)定義這些屬性和方法會(huì)使得項(xiàng)目出現(xiàn)代碼冗余并提高了維護(hù)難度,針對(duì)這種情況官方提供了Mixins特性,這時(shí)使用Vue mixins混入有很大好處,下面就介紹下Vue mixins混入使用方法,需要的朋友參考下吧
    2022-12-12
  • vue3版本網(wǎng)頁(yè)小游戲設(shè)計(jì)思路

    vue3版本網(wǎng)頁(yè)小游戲設(shè)計(jì)思路

    最近火爆全網(wǎng)的羊了個(gè)羊小程序,背景是根據(jù)官方介紹,“羊了個(gè)羊”是一款闖關(guān)消除小游戲,通關(guān)率不到0.1%。主要玩法為重疊的各類方塊,需要在下方7個(gè)欄內(nèi)完成消除,其特點(diǎn)就是“極難”,也因此成為熱門挑戰(zhàn),對(duì)vue3版本網(wǎng)頁(yè)小游戲設(shè)計(jì)思路感興趣的朋友跟隨小編一起看看吧
    2022-12-12
  • element-plus/element-ui走馬燈配置圖片及圖片自適應(yīng)的最簡(jiǎn)便方法

    element-plus/element-ui走馬燈配置圖片及圖片自適應(yīng)的最簡(jiǎn)便方法

    走馬燈功能在展示圖片時(shí)經(jīng)常用到,下面這篇文章主要給大家介紹了關(guān)于element-plus/element-ui走馬燈配置圖片及圖片自適應(yīng)的最簡(jiǎn)便方法,文中通過(guò)實(shí)例代碼介紹的非常詳細(xì),需要的朋友可以參考下
    2023-03-03

最新評(píng)論

稷山县| 湖南省| 丰顺县| 连云港市| 萨迦县| 盐城市| 望奎县| 刚察县| 西华县| 长武县| 黄浦区| 城口县| 台北市| 房产| 辽阳县| 桃源县| 芒康县| 云霄县| 萨嘎县| 临清市| 遂宁市| 措美县| 北票市| 周口市| 龙游县| 喀喇沁旗| 甘洛县| 汉川市| 牡丹江市| 涟水县| 赫章县| 溧水县| 成武县| 正阳县| 邯郸市| 株洲县| 淮滨县| 灵武市| 成安县| 明水县| 松江区|