2013-07-29 82 views
0

在下面的代碼,我需要從app.js傳遞text變量app_flip.js和那邊顯示它。我怎樣才能做到這一點 ?將參數傳遞給新的窗口[鈦]

**In app.js** 
var win = Titanium.UI.createWindow({backgroundColor:'white'}); 

button.addEventListener('click,function(e){ 
Ti.include('app_flip.js'); 
}); 
var text = Ti.UI.createLabel({ text:"hello" }); 
win.add(text); 

**In app_flip.js** 
var win = Titanium.UI.createWindow({backgroundColor:'white'}); 
+0

這是鈦最毆打的話題,如果你搜索你必須找到幾十個鏈接,因爲我要在這裏http://stackoverflow.com/questions/10098442/titanium-passing-variable-to-new粘貼一點點-window http://developer.appcelerator.com/question/132078/passing-variable-between-window http://developer.appcelerator.com/question/119798/how-do-i-pass-variables-from-one - 視圖到另一個http://developer.appcelerator.com/question/71401/how-do-i-pass-variables-from-one-page-to-another http://sushmapandey.wordpress.com/2011/04/11 /傳遞參數從 - currentwindow到的新窗口-i的 –

回答

0

您可以使用下面的方法 app.js

button.addEventListener('click', function(e){ 
    var win = Ti.UI.createWindow({ 
     url : 'app_flip.js', 
     backgroundColor : 'white', 
     _customProperty : 'Value of the property' 
    }); 

    win.open(); 
}); 

打開一個新窗口app_flip.js

var win = Ti.UI.currentWindow; 
var _customProperty = win._customProperty; 
alert(_customProperty); //Will display Value of the property 

您可以使用this作爲參考