当我使用require()
在页面上按下按钮时,我试图从主窗口传递数据,就像这样:
mapview.addEventListener('click', function(evt) {
var detailWindow = Ti.UI.createWindow({
backgroundColor: '#333333',
navTintColor: '#FFF',
barColor: '#222222',
itemID: evt.annotation.myid
});
Ti.API.info('detailWindow.itemID = ' + detailWindow.itemID);
// displays expected value from database eg 12345
detailWindow = require('ui/iphone/detail');
var detailWin = new myWindowHere(detailWindow.itemID);
}
Detail.js:
function myWindowHere(myItemID) {
var myDetailsWin = Titanium.UI.createWindow({
//properties here
});
Ti.API.info('myItemID = ' + myItemID); // this log is never
var facilityID = myItemID;
myWindowHere.open();
return myDetailsWin;
};
module.exports = myWindowHere;
但是,当我收到错误消息:Can't find variable: myItemID
请帮助!非常感谢
答案 0 :(得分:0)
尝试:
mapview.addEventListener('click', function(evt) {
var detailWindow = Ti.UI.createWindow({
backgroundColor: '#333333',
navTintColor: '#FFF',
barColor: '#222222',
itemID: evt.annotation.myid
});
Ti.API.info('detailWindow.itemID = ' + detailWindow.itemID);
// displays expected value from database eg 12345
var detailWin = require('ui/iphone/detail').myWindowHere(detailWindow.itemID);
}