[英]Strange javascript variable dumping
When calling console.dir(myVariable)
, I got this strange result: 当调用
console.dir(myVariable)
,我得到了这个奇怪的结果:
JS: === dump(): dumping function and properties names ===
JS: 0: [
JS: 1: o
JS: 2: b
JS: 3: j
JS: 4: e
JS: 5: c
JS: 6: t
JS: 7:
JS: 8: O
JS: 9: b
JS: 10: j
JS: 11: e
JS: 12: c
JS: 13: t
JS: 14: ]
JS: === dump(): finished ===
What does it means ? 这是什么意思 ? Why did I not get a standard object or array output ?
为什么我没有得到标准的对象或数组输出?
Please notice that I could not use chrome/firefox developper tool, as I am coding from Telerik NativeScript framework. 请注意,由于我是从Telerik NativeScript框架进行编码,因此无法使用chrome / firefox开发工具。
Also I am calling this code from a 'Code-Behind' for a component built in Angular 2. 我也从Angular 2中内置的组件的“隐藏代码”中调用此代码。
This is the html for the explorer component, explorer.html : 这是Explorer组件的explorer.html的HTML:
<ActionBar title="{{ 'activity_explorer' | L }}" android.icon="res://icon"
android.iconVisibilty="always">
<ActionItem icon="res://icon_plus" text="{{'menuitem_new' | L}}" (tap)="showMenuItemNew()"></ActionItem>
<ActionItem [icon]="selectionModeIcon()" text="selectionModeItemText()" (tap)="toggleSelectionMode()"></ActionItem>
</ActionBar>
<GridLayout rows="1*, 12*" modal-dialog-host>
<Label class="path_component" row="0" [text]="_path" textWrap="true"> </Label>
<ListView row="1" [items]="_files">
<template let-item="item">
<loloof64-explorer-item-line [checkboxVisible]="_selectionMode" item="{{item}}"></loloof64-explorer-item-line>
</template>
</ListView>
</GridLayout>
This is the html for explorer_item_line component : explorer_item_line.html 这是explorer_item_line组件的HTML:explorer_item_line.html
<GridLayout columns="1*, 1*, 7*">
<loloof64-checkbox #check_comp col="0" [visible]="checkboxVisible"> </loloof64-checkbox>
<Image col="1" (tap)="handleTap()" src="res://folder"></Image>
<Label col="2" (tap)="handleTap()" text="Text" textWrap="true"> </Label>
</GridLayout>
This is the ExploreItem class : 这是ExploreItem类:
export class ExplorerItem {
private _name: string;
private _isDirectory: boolean;
constructor(name: string, isDirectory: boolean){
this._name = name;
this._isDirectory = isDirectory;
}
name(){
return this._name;
}
isDirectory(){
return this._isDirectory;
}
public isParent() : boolean {
return this._name === ".." && this._isDirectory;
}
public static sort(left: ExplorerItem, right: ExplorerItem): number {
if (left.isDirectory() === right.isDirectory()) {
return left.name().toLowerCase().localeCompare(right.name().toLowerCase());
}
else {
return left.isDirectory() ? -1 : 1;
}
}
}
This is the explorer_item_line.ts : 这是explorer_item_line.ts:
import {Component, Input, ViewChild} from '@angular/core';
import {Checkbox} from "../checkbox/checkbox";
import {ExplorerItem} from "./explorer_item";
import * as _ from 'lodash';
@Component({
moduleId: module.id,
selector: 'loloof64-explorer-item-line',
templateUrl: 'explorer_item_line.html',
styleUrls: ['explorer_item_line.css'],
directives: [Checkbox]
})
export class ExplorerItemLine {
@Input() checkboxVisible: boolean = false;
@Input() item: any;
@ViewChild('check_comp') checkboxComp: Checkbox;
handleTap(){
if (this.checkboxVisible){
this.checkboxComp.checked = ! this.checkboxComp.checked;
}
console.log(JSON.stringify(this.item))
}
}
I think it is a binding problem between the explorer and explorer_item_line components, but I can't figure why and how to solve it. 我认为这是资源管理器和explorer_item_line组件之间的绑定问题,但是我无法弄清楚为什么以及如何解决它。
And finally, I land on Nativescript debugging page : so I should be able to inspect it in Chrome's developper tool. 最后,我进入了Nativescript调试页面:因此,我应该能够在Chrome的开发者工具中对其进行检查。
item="{{item}}
是NativeScript核心绑定的语法..其中NativeScript + Angular-2您应该使用ng-style,这意味着[item]="item"
在ng-app中使用核心语法会导致该值返回的类型为[object Object]
而不是您期望的值。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.