我想根据全局索引更改我的着名曲面的文本内容,但文本没有递增。这样做我怎么样?继承我的代码:
index = 0;是一个全局变量,它根据表面上的点击次数递增
Slideshow.js
function _createBackground() {
text = ['Hey', 'yo', '2'];
var background = new Surface({
content: text[index],
properties: {
backgroundColor: '#FFFFF6',
boxShadow: '0 10px 20px -5px rgba(0, 0, 0, 0.5)',
cursor: 'pointer',
}
});
this.mainNode.add(background);
background.on('click', function() {
this._eventOutput.emit('click');
}.bind(this));
}
Slideshowview.js
var index = 0;
SlideshowView.prototype.showCurrentSlide = function() {
this.ready = false;
var slide = this.slides[this.currentIndex];
console.log(this.currentIndex);
index = this.currentIndex;
this.lightbox.show(slide, function() {
this.ready = true;
slide.fadeIn();
}.bind(this));
};
答案 0 :(得分:0)
这是对您的通话程序的猜测,但您需要将索引范围纳入您的通话。
function _createBackground(index) {
text = ['Hey', 'yo', '2'];
var background = new Surface({
content: text[index],
properties: {
backgroundColor: '#FFFFF6',
boxShadow: '0 10px 20px -5px rgba(0, 0, 0, 0.5)',
cursor: 'pointer',
}
});
this.mainNode.add(background);
background.on('click', function() {
this._eventOutput.emit('click');
}.bind(this));
}
_createBackground.call(this, index);