我想将各个表面添加到Famo.us中的Scrollview。这是我到目前为止你能指出正确的方向。我只想添加surface1,surface2,surface3等。
Bellow是Famo.us代码示例..
var Engine = require("famous/core/Engine");
var Surface = require("famous/core/Surface");
var Scrollview = require("famous/views/Scrollview");
var mainContext = Engine.createContext();
var surface1;
var surface2;
var scrollview = new Scrollview();
var surfaces = [];
scrollview.sequenceFrom(surfaces);
surface1 = new Surface({
content: "<h1>Content 1</h1>",
size: [undefined, undefined],
properties: {
backgroundColor: "#2e3d52",
color: "#ffffff",
textAlign: 'center'
}
});
surface1.pipe(scrollview);
surfaces.push(surface1);
}
surface2 = new Surface({
content: "<h1>Content 2</h1>",
size: [undefined, undefined],
properties: {
backgroundColor: "#2e3d52",
color: "#ffffff",
textAlign: 'center'
}
});
surface2.pipe(scrollview);
surfaces.push(surface2);
}
mainContext.add(scrollview);
});
答案 0 :(得分:0)
你有额外的花括号......
试试这个..
var Engine = require("famous/core/Engine");
var Surface = require("famous/core/Surface");
var Scrollview = require("famous/views/Scrollview");
var mainContext = Engine.createContext();
var surface1;
var surface2;
var scrollview = new Scrollview();
var surfaces = [];
scrollview.sequenceFrom(surfaces);
surface1 = new Surface({
content: "<h1>Content 1</h1>",
size: [undefined, undefined],
properties: {
backgroundColor: "#2e3d52",
color: "#ffffff",
textAlign: 'center'
}
});
surface1.pipe(scrollview);
surfaces.push(surface1);
surface2 = new Surface({
content: "<h1>Content 2</h1>",
size: [undefined, undefined],
properties: {
backgroundColor: "#2e3d52",
color: "#ffffff",
textAlign: 'center'
}
});
surface2.pipe(scrollview);
surfaces.push(surface2);
mainContext.add(scrollview);