0

チタン初心者です。新しいページを作成しようとしましたが、エラーが見つかりました

[エラー] : スクリプト エラー = 変数が見つかりません: newCard.js のモジュール (21 行目)。[エラー] : スクリプト エラー = 'undefined' はオブジェクトではありません (FirstView.js で 'Ti.include("ui/common/newCard.js").createWindow' を評価しています) (46 行目)。

それは私のテストコードです

    function FirstView() {  
    var self = Ti.UI.createView();  

    var label = Ti.UI.createLabel({
        color:'black',
        text:String.format(L('welcome'),'(test)'),      
        top:'50',
        align:'center',
        height:'auto',
        width:'auto'
    });
    self.add(label);

    var txtClick=Ti.UI.createLabel({
        text:String.format(L('txtclick'),'- click here -'),
        color:'red',
        top:'180',
        align:'center',
        height:'auto',
        width:'auto'        
    });
    self.add(txtClick); 

    var show=Ti.UI.createImageView({
        top:'100',
        width:'172',
        height:'52',
        image:'/images/logo.png' 
    });
    self.add(show); 

    txtClick.addEventListener('click', function(e) {    
       var window = Ti.include("ui/common/newCard.js").createWindow({
        title:"new card a day"
       });
       window.open({
            animated:true
       }); 
    });

    return self;
}
module.exports = FirstView;

および cardNew.js

        function newCard(){
        var self = Ti.UI.createView({
            backgroundColor: 'black',
        });

        var show=Ti.UI.createImageView({
            top:'100',
            width:'172',
            height:'52',
            image:'/images/logo.png' 
        });
        self.add(show);

        return self;
    }
module.exports = newCard;

私を助けてください。ありがとうございました

4

1 に答える 1

4

イベントリスナーのコールバック内でコードを次のように変更してみてください。

var newCard = require("ui/common/newCard");
var win = new newCard();
win.open({animated:true});
于 2013-01-14T11:58:36.880 に答える