1 引入组件
<!--引入vant组件库--> <van-cell-group> <van-field value="{{ value }}" placeholder="请写评价" border="{{ false }}" bind:change="onContentChange" /> </van-cell-group> <van-rate value="{{ score }}" bind:change="onScoreChange" /> <!--<van-button type="default">上传图片</van-button>--> <van-button type="danger" size='large' bindtap="submit" >提交</van-button>
{ "usingComponents": { "van-field": "vant-weapp/field", "van-rate": "vant-weapp/rate", "van-button": "vant-weapp/button" } }
/** * 页面的初始数据 */ data: { detail: {}, content:'',//评价的内容, score:5 ,//当前评价的分数 }, submit:function(){ console.log(this.data.content);//评价 console.log(this.data.score);//评分 }, //事件处理函数,当评价改变时调用 onContentChange: function (event){ this.setData({ content:event.detail }); console.log(this.data.content); }, onScoreChange:function(event){ this.setData({ //value: event.detail score:event.detail }); },