如果我尝试在 appcelerator 上打开新视图时出错
Error if I try to open new View on appcelerator
我正在使用 appcelerator 构建一个简单的应用程序。
所以我有索引视图,当应用程序启动时,我希望这个索引视图打开登录视图。
所以我有这个:
login.xml
<Alloy>
<View class="container">
<View class="images"></View>
<Label id="loginLable"
class="loginLable">Accedi</Label>
<TextField class="textLogin"></TextField>
</View>
</Alloy>
login.js
// Arguments passed into this controller can be accessed via the `$.args` object directly or:
var args = $.args;
function loginEventListener(e){
Ti.API.info("You clicked the button");
};
index.js
var login = Alloy.createController("login",args).getView();
login.open();
如果我尝试启动这个应用程序,我会遇到这个错误:
[ERROR] : TiExceptionHandler: (main) [19654,21610] ----- Titanium Javascript Runtime Error -----
[ERROR] : TiExceptionHandler: (main) [0,21610] - In alloy/controllers/index.js:35,11
[ERROR] : TiExceptionHandler: (main) [2,21612] - Message: Uncaught TypeError: Object #<View> has no method 'open'
[ERROR] : TiExceptionHandler: (main) [1,21613] - Source: login.open();
[ERROR] : V8Exception: Exception occurred at alloy/controllers/index.js:35: Uncaught TypeError: Object #<View> has no method 'open'
您无法 "open" 查看。它需要一个容器。您可以将其添加到已打开的 window,或者您需要将控制器设为 window。 open()
不存在该视图。
<Alloy>
<Window>
<View class="container">
<View class="images"></View>
<Label id="loginLable"
class="loginLable">Accedi</Label>
<TextField class="textLogin"></TextField>
</View>
</Window>
</Alloy>
然后,要打开它,您可以像之前那样做
我正在使用 appcelerator 构建一个简单的应用程序。 所以我有索引视图,当应用程序启动时,我希望这个索引视图打开登录视图。
所以我有这个:
login.xml
<Alloy>
<View class="container">
<View class="images"></View>
<Label id="loginLable"
class="loginLable">Accedi</Label>
<TextField class="textLogin"></TextField>
</View>
</Alloy>
login.js
// Arguments passed into this controller can be accessed via the `$.args` object directly or:
var args = $.args;
function loginEventListener(e){
Ti.API.info("You clicked the button");
};
index.js
var login = Alloy.createController("login",args).getView();
login.open();
如果我尝试启动这个应用程序,我会遇到这个错误:
[ERROR] : TiExceptionHandler: (main) [19654,21610] ----- Titanium Javascript Runtime Error -----
[ERROR] : TiExceptionHandler: (main) [0,21610] - In alloy/controllers/index.js:35,11
[ERROR] : TiExceptionHandler: (main) [2,21612] - Message: Uncaught TypeError: Object #<View> has no method 'open'
[ERROR] : TiExceptionHandler: (main) [1,21613] - Source: login.open();
[ERROR] : V8Exception: Exception occurred at alloy/controllers/index.js:35: Uncaught TypeError: Object #<View> has no method 'open'
您无法 "open" 查看。它需要一个容器。您可以将其添加到已打开的 window,或者您需要将控制器设为 window。 open()
不存在该视图。
<Alloy>
<Window>
<View class="container">
<View class="images"></View>
<Label id="loginLable"
class="loginLable">Accedi</Label>
<TextField class="textLogin"></TextField>
</View>
</Window>
</Alloy>
然后,要打开它,您可以像之前那样做