为页面中的变量赋值

1,294 views

在函数中为页面中变量赋值。

var page=this;
page.setData({ name: this.data.list[1].name})
简单播放器代码。
Page({
/**
* 页面的初始数据 */
onReady: function (e) {
this.audioCtx = wx.createAudioContext(‘myAudio’, this),
this.audioCtx.play()
},
data: {
myAudio:’myAudio’,
poster: ‘music.jpg’,
name: ‘送别’,
author: ‘朴树’,
src: ‘朴树-送别.mp3’,
list: [{
id: 1,
poster: ‘music.jpg’,
name: ‘送别’,
author: ‘朴树’,
src: ‘朴树-送别.mp3’
}, {
id: 2,
poster: ‘music.jpg’,
name: ‘我们的时光’,
author: ‘赵雷’,
src: ‘赵雷-我们的时光.mp3’
}, {
id: 3,
poster: ‘music.jpg’,
name: ‘杭盖’,
author: ‘杭盖乐队’,
src: ‘ 杭盖-杭盖.mp3’
}],
},
audioPlay:function(){
this.audioCtx.play()
},
audioPause:function(){
this.audioCtx.pause();
},
audioNext:function(){
this.audioCtx.setSrc(this.data.list[1].src),
this.audioCtx.play()
var page=this;
page.setData({ name: this.data.list[1].name})
},
audioStart:function(){
this.audioCtx.seek(0);
},
})
如果您觉得这篇文章对您有帮助,欢迎继续关注本站!!!我要赞助本站>>>

Leave a Reply

电子邮件地址不会被公开。 必填项已用*标注