為頁面中的變量賦值

6,513 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

電子郵件地址不會被公開。 必填項已用*標注