Ionic framework Ionic运行时错误无法读取属性“0”;toLowerCase“;空的
我试图通过“ionic serve”查看应用程序,但出现此错误。我看过其他主题,但从未见过运行时错误。我尝试了他们的所有解决方案,但仍然会出现相同的错误页面。以下是我看到的: 老实说,我不是这个应用的编码员,但我是从商店买的。但是,我到处都知道一些。如果有一个简单的解决方案来解决这个问题,那将是惊人的 第一个错误链接指向此处:Ionic framework Ionic运行时错误无法读取属性“0”;toLowerCase“;空的,ionic-framework,runtime,Ionic Framework,Runtime,我试图通过“ionic serve”查看应用程序,但出现此错误。我看过其他主题,但从未见过运行时错误。我尝试了他们的所有解决方案,但仍然会出现相同的错误页面。以下是我看到的: 老实说,我不是这个应用的编码员,但我是从商店买的。但是,我到处都知道一些。如果有一个简单的解决方案来解决这个问题,那将是惊人的 第一个错误链接指向此处: _this.initialData(); var operating_system = ''; var admob = {}; if (_this.device.pla
_this.initialData();
var operating_system = '';
var admob = {};
if (_this.device.platform.toLowerCase() == 'android') {
operating_system = 'android';
admob = {
banner: settings['admob_android_banner'],
interstitial: settings['admob_android_interstitial']
};
}
SafeSubscriber.prototype.next = function (value) {
if (!this.isStopped && this._next) {
var _parentSubscriber = this._parentSubscriber;
if (!_parentSubscriber.syncErrorThrowable) {
this.__tryOrUnsub(this._next, value);
}
else if (this.__tryOrSetError(_parentSubscriber, this._next, value)) {
this.unsubscribe();
}
}
Subscriber.prototype._next = function (value) {
this.destination.next(value);
};
var /** @type {?} */ response = new Response(responseOptions);
response.ok = isSuccess(status);
if (response.ok) {
responseObserver.next(response);
// TODO(gdi2290): defer complete if array buffer until done
responseObserver.complete();
return;
}
第二个错误链接指向这里:
SafeSubscriber.prototype.__tryOrUnsub = function (fn, value) {
try {
fn.call(this._context, value);
}
catch (err) {
this.unsubscribe();
throw err;
}
};
第三个错误指向这里:
_this.initialData();
var operating_system = '';
var admob = {};
if (_this.device.platform.toLowerCase() == 'android') {
operating_system = 'android';
admob = {
banner: settings['admob_android_banner'],
interstitial: settings['admob_android_interstitial']
};
}
SafeSubscriber.prototype.next = function (value) {
if (!this.isStopped && this._next) {
var _parentSubscriber = this._parentSubscriber;
if (!_parentSubscriber.syncErrorThrowable) {
this.__tryOrUnsub(this._next, value);
}
else if (this.__tryOrSetError(_parentSubscriber, this._next, value)) {
this.unsubscribe();
}
}
Subscriber.prototype._next = function (value) {
this.destination.next(value);
};
var /** @type {?} */ response = new Response(responseOptions);
response.ok = isSuccess(status);
if (response.ok) {
responseObserver.next(response);
// TODO(gdi2290): defer complete if array buffer until done
responseObserver.complete();
return;
}
第四个错误指向这里:
_this.initialData();
var operating_system = '';
var admob = {};
if (_this.device.platform.toLowerCase() == 'android') {
operating_system = 'android';
admob = {
banner: settings['admob_android_banner'],
interstitial: settings['admob_android_interstitial']
};
}
SafeSubscriber.prototype.next = function (value) {
if (!this.isStopped && this._next) {
var _parentSubscriber = this._parentSubscriber;
if (!_parentSubscriber.syncErrorThrowable) {
this.__tryOrUnsub(this._next, value);
}
else if (this.__tryOrSetError(_parentSubscriber, this._next, value)) {
this.unsubscribe();
}
}
Subscriber.prototype._next = function (value) {
this.destination.next(value);
};
var /** @type {?} */ response = new Response(responseOptions);
response.ok = isSuccess(status);
if (response.ok) {
responseObserver.next(response);
// TODO(gdi2290): defer complete if array buffer until done
responseObserver.complete();
return;
}
第五个错误指向这里:
_this.initialData();
var operating_system = '';
var admob = {};
if (_this.device.platform.toLowerCase() == 'android') {
operating_system = 'android';
admob = {
banner: settings['admob_android_banner'],
interstitial: settings['admob_android_interstitial']
};
}
SafeSubscriber.prototype.next = function (value) {
if (!this.isStopped && this._next) {
var _parentSubscriber = this._parentSubscriber;
if (!_parentSubscriber.syncErrorThrowable) {
this.__tryOrUnsub(this._next, value);
}
else if (this.__tryOrSetError(_parentSubscriber, this._next, value)) {
this.unsubscribe();
}
}
Subscriber.prototype._next = function (value) {
this.destination.next(value);
};
var /** @type {?} */ response = new Response(responseOptions);
response.ok = isSuccess(status);
if (response.ok) {
responseObserver.next(response);
// TODO(gdi2290): defer complete if array buffer until done
responseObserver.complete();
return;
}
以下是我在cmd中得到的代码:
C:\Users\xx nj\Desktop\DukhanApp\DukhanColor>爱奥尼亚服务
正在启动应用程序脚本服务器:--地址0.0.0.0--端口8100--livereload端口35729--开发记录器端口53703--nobrowser-
按Ctrl+C键取消
[20:02:52]开始观察。。。
[20:02:52]已启动生成开发。。。
[20:02:53]清洁开始。。。
[20:02:53]清洁在3毫秒内完成
[20:02:53]复制已开始。。。
[20:02:53]深度链接已启动。。。
[20:02:53]deeplinks在573毫秒内完成
[20:02:53]传输已开始。。。
[20:03:01]Transbile在7.70秒内完成
[20:03:01]预处理已开始。。。
[20:03:01]预处理在1毫秒内完成
[20:03:01]网页包已启动。。。
[20:03:01]复制在8.80秒内完成
[20:03:09]网页在8.01秒内完成
[20:03:09]sass开始。。。
如果没有“from”选项,PostCs可能会生成错误的源映射,并且找不到Browserslist配置。将其设置为CSS文件路径或“未定义”以防止出现此警告。
[20:03:13]sass以3.39秒完成
[20:03:13]后处理已启动。。。
[20:03:13]后处理在14毫秒内完成
[20:03:13]开始起绒。。。
[20:03:13]构建开发在20.14秒内完成
[20:03:13]20.44秒后手表准备就绪
[20:03:13]正在运行的开发服务器:http://localhost:8100/
[确定]开发服务器正在运行!
本地:http://localhost:8100
外部:http://192.168.8.111:8100
德瓦普:塞尔托_ionic3@8100在Najms笔记本电脑上
[20:03:23]tslint:C:/Users/xx nj/Desktop/DukhanApp/DukhanColor/src/pages/contactus/contactus.ts,第124行
“标记”已声明,但从未使用过。
L123:let map=new google.maps.map(元素,mapOptions);
L124:let marker=new google.maps.marker({
L125:title:this.textStatic['cellstore\u contact\u us\u title'],
[20:03:23]tslint:…s/xx nj/Desktop/DukhanApp/DukhanColor/src/pages/detailcategory/detailcategory.ts,第138行
重复变量:“过滤器”
L138:for(此.filter['valueCustom']中的变量筛选器){
L139:让attr=this.filter['value'][filter];
[20:03:23]tslint:…s/xx nj/Desktop/DukhanApp/DukhanColor/src/pages/detailcategory/detailcategory.ts,第140行
重复变量:“选项”
L139:让attr=this.filter['value'][filter];
L140:if(attr&&Object.keys(attr).length>0)for(attr中的var选项){
L141:if(选项!=“选择”&&attr[选项]){
[20:03:23]tslint:C:/Users/xx nj/Desktop/DukhanApp/DukhanColor/src/pages/brand/brand.ts,第121行
重复变量:“过滤器”
L121:for(此.filter['valueCustom']中的变量筛选器){
L122:让attr=this.filter['value'][filter];
[20:03:23]tslint:C:/Users/xx nj/Desktop/DukhanApp/DukhanColor/src/pages/brand/brand.ts,第123行
重复变量:“选项”
L122:让attr=this.filter['value'][filter];
L123:if(attr&&Object.keys(attr).length>0)for(attr中的var选项){
L124:if(选项!=“选择”&&attr[选项]){
[20:03:23]tslint:C:/Users/xx nj/Desktop/DukhanApp/DukhanColor/src/pages/home/home.ts,第300行
重复变量:“diff”
L299:element[i][“到期日”]=false;
L300:var diff=(start.getTime()-today.getTime())/1000;
L301:元素[i]['time_diff']=数学层(diff);
[20:03:23]tslint:C:/Users/xx nj/Desktop/DukhanApp/DukhanColor/src/pages/home/home.ts,第165行
已声明“剩余时间”,但从未使用过。
L164:ngOnInit(){
L165:var剩余时间=设置间隔(()=>{
L166:if(this.navCtrl.getActive().component.name==“HomePage”){
[20:03:23]tslint:C:/Users/xx nj/Desktop/DukhanApp/DukhanColor/src/pages/search/search.ts,第213行
重复变量:“过滤器”
L213:for(此.filter['valueCustom']中的变量筛选器){
L214:让attr=this.filter['value'][filter];
[20:03:23]tslint:C:/Users/xx nj/Desktop/DukhanApp/DukhanColor/src/pages/search/search.ts,第215行
重复变量:“选项”
L214:让attr=this.filter['value'][filter];
L215:if(attr&&Object.keys(attr).length>0)for(attr中的var选项){
L216:if(选项!=“选择”&&attr[选项]){
[20:03:23]lint在10.05秒内完成
似乎平台没有正确返回,这就是它为空的原因
您没有包含构造函数,所以我不知道您的构造函数是什么样子的,但是下面的代码片段使用您在代码中使用的正确返回了平台名称
import { Device } from '@ionic-native/device';
constructor(private device: Device) {}
......
if(this.device.platform.toLowerCase()=='android'){
// Your logic here
}
这是因为您正在web上运行ionic Service,而cordova平台在那里不可用。ionic Native在属性不存在时(cordova不可用时)返回{},并抛出控制台警告以获得开发人员帮助。 当试图从{}对象检索数据时,它将返回null。
请尝试添加以下代码:
import { Platform } from 'ionic-angular';
//add it in constructor as follows:
constructor( public platform: Platform){
}
//add platform check
if (this.platform.is('cordova')) {
//add your code here
}else{
console.log("Plugin not supported on web");
}
如果没有任何代码,就很难找到您的错误。我是否应该将每一行的所有代码都放在提到的文件中?可能是使用
toLowerCase()
的最小上下文。我添加了一些代码错误指向hi@Najm AlDekhel,您必须在页面中添加此代码,您已经在代码中检查了平台。