赞
踩
- <view class="box4">{{time}}</view>
- <button bind:tap="recorderBtn">开始录音</button>
- <button bind:tap="removeBtn">结束录音</button>
- <button bind:tap="playBtn">播放录音</button>
JS
- Page({
- data:{
- time:0,
- clearTime:"",
- fileText:"",
- },
- recorderBtn(){
- this.data.clearTime = setInterval(()=>{
- this.data.time += 1;
- this.setData({time:this.data.time});
- },1000);
- a.start()
- },
- removeBtn(){
- clearInterval(this.data.clearTime);
- this.setData({time:0})
- a.stop();
- a.onStop((res)=>{
- this.data.fileText = res.tempFilePath;
- })
- },
- playBtn(){
- b.src = this.data.fileText;
- b.play();
- },

wxml
- <button class="avatar-wrapper" open-type="chooseAvatar" bindchooseavatar="onChooseAvatar">
- <image class="avatar" src="{{ avatarUrl }}" />
- </button>
- .avatar-wrapper {
- width: 160rpx;
- height: 160rpx;
- padding: 0;
- background: none;
- }
- .avatar {
- width: 160rpx;
- height: 160rpx;
- border-radius: 20rpx;
- }
js
- const defaultAvatar = '../../images/banner.jpg';
- Page({
- data:{
- avatarUrl:defaultAvatar,}
- )},
-
- onChooseAvatar(e){
- console.log(e);
- const { avatarUrl } = e.detail
- this.setData({ avatarUrl })
- },
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。