가장 적합 한 vue.js 의 form 제출 은 여러 플러그 인 과 관련 됩 니 다[추천]

8538 단어 vue.jsform
vue.js 를 기반 으로 작은 열 을 썼 습 니 다.vue.js 동적 추가 css 스타일,tab 전환,touch,폼 제출,검증,toast,데이터 양 방향 연결 등 과 관련된다.
먼저 효과 도 를 올 리 고 다시 설명 합 니 다.

첫째,동적 수정 css

X 를 누 르 면 따뜻 한 알림 을 숨 깁 니 다:
1.전체 div 에 v-bind 연결 하기

<div class="rz-notice" v-bind:style="{ display: isno}">
    <p>           ,    :<img src="../assets/static/img-icon/lan_cha.png" @click="hiddenwords"></p>
 </div>
설명:그림 주 소 는 당신 의 주소 입 니 다.

<div class="rz-notice" v-bind:style="{ display: isno}">
 <p>           ,    :
  <img src="../assets/static/imgicon/lan_cha.png" @click="hiddenwords"></p>
</div>
2.data 에서 정의isno:'block',:3.click 이벤트 작성 방법

methods: {
  hiddenwords() {
  this.isno = 'none'
  },
}
간단 한 클릭 설정 스타일 을 none 으로 쓰 면 됩 니 다.
당신 의 업무 수요 에 따라 동적 으로 추 가 된 스타일 을 쓰 십시오.방법 은 모두 같다.
2.다음 에 제출 할 때 가장 흔히 볼 수 있 는 검증 을 작성 합 니 다.

Toast 스타일 은 제 주제 색 에 맞 게 수정 을 했 습 니 다.Toast import { Toast } from 'vant'2.1 여 기 는 v-modal 데이터 의 양 방향 연결 과 관련된다.

<div class="my-content-list">
 <div class="color-black"><span style="margin-right: 0.6rem;">
      :</span><input v-model="yoursname" placeholder="         " /></div>
</div>
<div class="my-content-list">
 <div class="color-black"><span style="margin-right: 0.6rem;">    :</span>
 <input v-model="yoursphone" placeholder="         " /></div>
</div>
<div class="yzbtn" @click="submitBtn">    </div>
2.2 data 에서 yoursname 과 yoursphone 의 초기 값 을 정의 합 니 다.

yoursname: ' ',
 yoursphone: ' ',
2,3 쓰기 방법 z

submitBtn() {
 var reg = /^1[3|4|5|8][0-9]\d{4,8}$/;
 if(this.yoursname == '') {
 Toast("         ");
 return;
 }
 if(this.yoursphone == '' || this.yoursphone == null) {
 Toast("         ");
 return;
 }
 if(!reg.test(this.yoursphone)) {
 Toast('         ');
 return;
 }
},
그림 업로드 및 미리 보기 그림 은 다음 글 에서 매주 작은 열 과 플러그 인 방법 을 업데이트 합 니 다.
마지막 으로 전체 코드 를 첨부 합 니 다.
당신 의 귀중 한 의견 을 제기 하여 함께 진보 하 는 것 을 환영 합 니 다.

<template>
 <div class="renzheng">
 <div class="rz-notice" v-bind:style="{ display: isno}">
 <p>           ,    :<img src="../assets/static/img-icon/lan_cha.png" @click="hiddenwords"></p>
 </div>
 <van-tabs v-model="active" swipeable>
 <van-tab v-for="(item,index) in navArr" :title="item.name" class="v-tab">
 <div v-if="index==0">
  <div class="color-black" style="text-align: center;margin-top: 0.4rem;">         </div>
  <div class="rz-picter">
  <img src="../assets/jia.jpg" />
  <p><input type="file" style="display: none;" >    </p>
  </div>
  <div class="cuxian"></div>
  <!--
        :[email protected]
        :2018-08-24
        :form  
      -->
  <div class="my-content-list">
  <div class="color-black"><span style="margin-right: 0.6rem;">    :</span><input v-model="yoursname" placeholder="         " /></div>
  </div>
  <div class="my-content-list">
  <div class="color-black"><span style="margin-right: 0.6rem;">    :</span><input v-model="yoursphone" placeholder="         " /></div>
  </div>
  <div class="yzbtn" @click="submitBtn">
      
  </div>
 </div>
 <div v-if="index==1">
  <div class="color-black" style="text-align: center;margin-top: 0.4rem;">          </div>
  <div class="rz-picter">
  <img src="../assets/jia.jpg" />
  <p>     </p>
  </div>
  <div class="rz-picter">
  <img src="../assets/jia.jpg" />
  <p>     </p>
  </div>
  <div class="cuxian"></div>
  <div class="my-content-list">
  <div class="color-black"><span style="margin-right: 0.6rem;">    :</span><input placeholder="         " /></div>
  </div>
  <div class="my-content-list">
  <div class="color-black"><span style="margin-right: 0.6rem;">    :</span><input type="number" placeholder="         " /></div>
  </div>
  <div class="yzbtn">
      
  </div>
 </div>
 </van-tab>
 </van-tabs>
 </div>
</template>
<script>
 import { Tab, Tabs } from 'vant';
 import { Toast } from 'vant'
 export default {
 name: 'renzheng',
 data() {
 return {
 yoursname: '',
 yoursphone: '',
 
 isno:'block',
 active: 0,
 navArr: [{
  name: "    "
  },
  {
  name: "    "
  }
 ],
 }
 },
 methods: {
 hiddenwords() {
 this.isno = 'none'
 },
 submitBtn() {
 var reg = /^1[3|4|5|8][0-9]\d{4,8}$/;
 if(this.yoursname == '') {
  Toast("         ");
  return;
 }
 if(this.yoursphone == '' || this.yoursphone == null) {
  Toast("         ");
  return;
 }
 if(!reg.test(this.yoursphone)) {
  Toast('         ');
  return;
 }
 },
 
 }
 }
</script>
<style>
 .rz-notice {
 padding: 0.2rem 0.3rem;
 display: flex;
 flex-direction: row;
 justify-content: space-between;
 align-items: center;
 background: #F0F5FB;
 color: #28D9EF;
 }
 
 .rz-notice img {
 height: 0.22rem;
 width: 0.22rem;
 }
 
 .rz-picter {
 height: 3rem;
 width: 6rem;
 margin: 0.3rem auto;
 border: 0.01rem solid #ededed;
 display: flex;
 flex-direction: column;
 align-items: center;
 justify-content: center;
 }
 /*    */
 
 .yzbtn {
 width: 90%;
 height: 0.8rem;
 background: #FF6600;
 border-radius: 0.06rem;
 margin: 30px auto;
 text-align: center;
 line-height: 0.8rem;
 color: #FFFFFF
 }
 /*    tab  */
 
 .van-tab {
 color: #A3A3A3!important;
 }
 
 .van-tab--active {
 color: #000!important;
 }
 
 .van-tabs__line {
 background-color: #FF6600!important;
 width: 0.7rem!important;
 text-align: center!important;
 align-items: center;
 margin-left: 1.5rem;
 }
 
 .van-toast {
 background-color: #FF6600;
 color: #FFFFFF
 }
 
 .my-content-list {
 padding: 0.3rem;
 display: flex;
 flex-direction: row;
 justify-content: space-between;
 border-bottom: 0.01rem solid #EDEDED;
 }
</style>
총결산
위 에서 말 한 것 은 소 편 이 여러분 에 게 소개 하 는 가장 적합 한 vue.js 의 form 제출 은 여러 가지 플러그 인 과 관련 되 어 있 습 니 다.여러분 에 게 도움 이 되 기 를 바 랍 니 다.궁금 한 점 이 있 으 시 면 저 에 게 메 시 지 를 남 겨 주세요.소 편 은 제때에 답 해 드 리 겠 습 니 다.여기 서도 저희 사이트 에 대한 여러분 의 지지 에 감 사 드 립 니 다!

좋은 웹페이지 즐겨찾기