簡體   English   中英

未捕獲的TypeError:無法在file:///android_asset/www/app.js讀取未定義的屬性'connection':1

[英]Uncaught TypeError: Cannot read property 'connection' of undefined at file:///android_asset/www/app.js:1

我不知道錯誤在哪里以及如何刪除它。 我是sencha touch和phonegap的新手。 這是我的app.js文件

//不要刪除 - Sencha Cmd包需要此指令才能工作。 // @ require @packageOverrides

// Ext.Loader.setPath({'Ext':'touch / src'}); //

Ext.application({
name: 'appointMeDr',

requires: [
'Ext.MessageBox','Ext.device.Connection','appointMeDr.SessionInfo',
'Ext.data.proxy.LocalStorage','Ext.data.proxy.LocalStorage'
],

views: [
'Main','homePage.Home','viewsTab.FindDrTab','viewsTab.SettingTab',
'profile.user_profile','userAppointment.PatientAppointment',
'doctorViews.MainDr','doctorViews.drAppointment.DrAppointment','doctorViews.doctorProfile.BlockPatient',
'doctorViews.tabViews.DrProfileTab',
'MyPicker','Utils',
'signUp.UserSignUp','signUp.SignUp',
'guardianView.GuardianPatient','guardianView.guardianProfile.GuardianProfile','guardianView.MainGuardian',    
'attendant.MainAttendant','attendant.tabViews.AttendantProfileTab','HealthyTips'

],
models:[
'SearchDr','fixedAppointment','Patient','Login','user','DoctorModel','AppointmentModel','Guardian','DoctorDetail',
'doctorAppointment','Attendant','HealthyTipModel'
],
stores:[
'SearchDocResults','AppointmentResults','Patients','Users','OfflineUser','Doctors','Guardians','DoctorDetailsStore',
'doctorAppointments','AttendantStore','BlockPatients','TimeSlots','HealthyTips'
],
controllers: [
'LoginController','MainController','DoctorController','UserSignUp','AppointmentController','AttendantController',
'GuardianController'

],

icon: {
    '57': 'resources/icons/Icon.png',
    '72': 'resources/icons/Icon~ipad.png',
    '114': 'resources/icons/Icon@2x.png',
    '144': 'resources/icons/Icon~ipad@2x.png'
},

isIconPrecomposed: true,

startupImage: {
    '320x460': 'resources/startup/320x460.jpg',
    '640x920': 'resources/startup/640x920.png',
    '768x1004': 'resources/startup/768x1004.png',
    '748x1024': 'resources/startup/748x1024.png',
    '1536x2008': 'resources/startup/1536x2008.png',
    '1496x2048': 'resources/startup/1496x2048.png'
},

launch: function() {
    // Destroy the #appLoadingIndicator element
   // Ext.fly('appLoadingIndicator').destroy();
Ext.Viewport.add(Ext.create('appointMeDr.view.homePage.Home'));
    // Initialize the main view
   // Ext.Viewport.add(Ext.create('appointMeDr.view.Main'));
},

onUpdated: function() {
    Ext.Msg.confirm(
        "Application Update",
        "This application has just successfully been updated to the latest version. Reload now?",
        function(buttonId) {
            if (buttonId === 'yes') {
                window.location.reload();
            }
        }
    );
}

});

我們不知道你想做什么,但我嘗試了一些事情:

我想你在“ deviceready ”事件之前調用connection.type屬性。

來自phonegap doc:

這是每個Cordova應用程序都應該使用的非常重要的事件。

Cordova包含兩個代碼庫:本機代碼和JavaScript代碼。 在加載本機代碼時,會顯示自定義加載圖像。 但是,只有在DOM加載后才會加載JavaScript。 這意味着您的Web應用程序可能會在加載之前調用Cordova JavaScript函數。

一旦Cordova滿載,Cordova deviceready事件就會發生。 設備觸發后,您可以安全地調用Cordova功能。

試試這個:

// Wait for PhoneGap to load
// 
document.addEventListener("deviceready", onDeviceReady, false);

// PhoneGap is loaded and it is now safe to make calls PhoneGap methods
//
function onDeviceReady() {
    checkConnection();
}

function checkConnection() {
    var networkState = navigator.network.connection.type;
    ...
}

編輯 :現在我們有更多的信息,我認為這個答案對你沒用:/

經過2天的艱苦努力,我自己解決了。即使“”,“”(逗號生成它)也可以發出所有警告。 問題解決了:)快樂的編碼

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM