微信小程序调查问卷

首先我做的这个是评教系统中调查问卷页面并实现该功能

<view class='header'>被评教师:{{teachername}}</view>
<swiper bindchange='swiper_change' current='{{currentid}}'>
<block class="center" wx:for="{{paperdetails}}"><swiper-item class="tip"><text>{{index+1}}{{item.content}}</text><radio-group class="radio-group" bindchange="radioChange" data-id="{{item.id}}"><label class="radio"><radio value="a#{{item.scorea}}" /><text>A{{item.itema}}</text></label><label class="radio"><radio value="b#{{item.scoreb}}" /><text>B{{item.itemb}}</text></label><label class="radio" wx:if="{{item.itemc!=''}}"><radio value="c#{{item.scorec}}" /><text>C{{item.itemc}}</text></label><label class="radio" wx:if="{{item.itemd!=''}}"><radio value="d#{{item.scored}}" /><text>D{{item.itemd}}</text></label> </radio-group></swiper-item></block></swiper >

第一行是点那个老师后出现哪个老师名字

当一页选完之后会自动跳转到下一页实现代码如

 //自动跳转radioChange: function(e){// setTimeout(this.next,1000);console.log(e);var id = e.target.dataset.id;console.log(id);var str = e.detail.value;var arr = new Array();//定义数组arr = str.split("#");//字符分割var answer = this.data.answer;answer[id] = arr[0];var score = this.data.score;score[id] = arr[1];this.setData({answer: answer,score:score});setTimeout(this.next,1000);},

当到达最后一页时提交问卷和留言会自动跳出这是因为使用if判断是否到达最后一页如果到达就让它显示

wx:if="{{currentid==count-1}}"

Published by

风君子

独自遨游何稽首 揭天掀地慰生平