message =“'undefined'不是钛中的函数(评估'bookview.open()')”

时间:2014-07-02 10:36:56

标签: titanium titanium-mobile titanium-alloy

我是TitaniumMobile的新手,我目前正在关注官方tutorials,但我还是在做这个阶段

function showBook(event) {
    var selectedBook = event.source;var args = {
        title: selectedBook.title,
        author: selectedBook.author
    };
    var bookview = Alloy.createController("bookdetails", args).getView();
    bookview.open();
}      

当我尝试使用ios模拟器运行时,我遇到了上述阶段,并发生以下错误。

  Script Error {
[ERROR] :      backtrace = "#0 () at :0";
[ERROR] :      line = 27;
[ERROR] :      message = "'undefined' is not a function (evaluating 'bookview.open()')";
[ERROR] :      name = TypeError;
[ERROR] :      sourceId = 344963552;
[ERROR] :      sourceURL = "file:///Users/hivelocity/Library/Application%20Support/iPhone%20Simulator/7.1/Applications/6B8062FB-B379-407A-8553-184EED274850/FaveBooks.app/alloy/controllers/index.js";
[ERROR] :  }

1 个答案:

答案 0 :(得分:9)

确保bookdetails是一个窗口而不是视图。

要检查,只需打开bookdetails.xml并检查Window的标签是否存在。