가장 적합 한 vue.js 의 form 제출 은 여러 플러그 인 과 관련 됩 니 다[추천]
먼저 효과 도 를 올 리 고 다시 설명 합 니 다.
첫째,동적 수정 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 제출 은 여러 가지 플러그 인 과 관련 되 어 있 습 니 다.여러분 에 게 도움 이 되 기 를 바 랍 니 다.궁금 한 점 이 있 으 시 면 저 에 게 메 시 지 를 남 겨 주세요.소 편 은 제때에 답 해 드 리 겠 습 니 다.여기 서도 저희 사이트 에 대한 여러분 의 지지 에 감 사 드 립 니 다!
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
[백견불여일타/Vue.js] 4장 - 입력 폼 데이터 가져오기v-model 데이터 입력 select 지난 장에서는 v-bind를 이용해서 HTML 태그 속성 값을 Vue로 다루는 법을 배웠습니다. 이번에는 사용자가 입력한 데이터를 Vue로 가져오는 법에 대해 다룹니다. 웹 페...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.