Cannot-call-method substring of undefined sencha-touch-all.js

来源:互联网 发布:燃烧的法庭 知乎 编辑:程序博客网 时间:2024/06/06 00:35

今天写sencha touch页面跳转时遇到了这个bug,怎么找都找不到错误
先贴出错误代码

Ext.define("NotesApp.view.View1", {    extend: "Ext.Container",   // alias: "widget.view1",  config:{    id:'view1',    layout:        {          type:'fit'        },        items:        {            xtype: "button",            text:"第一页",            centered: true,            iconMask: true,            itemId: "FirstButton"        },        listeners:        {          delegate: "#FirstButton",          event: "tap",          fn: "onFirstButtonHandler"            }},        onFirstButtonHandler: function ()         {               console.log("enter onNewNoteHandler");         this.fireEvent("FirstEvent", this);        }});

下面是app.js里的调用

function onDeviceReady(){    console.log("device ready2");    Ext.application({    name: "NotesApp",    controllers: ["myController"],    views: ["View1", "View2"],    launch: function () {        var View1 = {            xtype: "view1"        };        var View2 = {            xtype: "view2"        };        Ext.Viewport.add([View1, View2]);        console.log("quit onNewNoteHandler");    }});}

虽然应用能加载,但出来的全是白屏
google后在一个帖子里发现了这么一句话:
Because the code is not checking that an object is undefined before calling the .substring method on it.

大致是你引用了一个对象或类却没有声明,
首先是看看标示符有没有拼错,或者方法名有没有拼错
发现了一个地方拼错了,然后还不行,
回头去翻《深入浅出phonegap》的有关部分,发现了下面一句

这里写图片描述

原因是没有添加

alias: "widget.view1",  

这句话,导致在app.js里产生了未知引用,报出上面的错误。

————————————————————————
此外还有一个错误,是跟这个一起出现的
Unknown chromium error: -6
这个bug会出现在你写了不存在的标示符的时候出现,比如把view1写成view2。

——————————————————
sencha touch的页面跳转至今还没搞定,努力中……….

0 0
原创粉丝点击