奇怪的javascript变量转储
调用奇怪的javascript变量转储,javascript,nativescript,dumping,Javascript,Nativescript,Dumping,调用console.dir(myVariable)时,我得到了一个奇怪的结果: JS: === dump(): dumping function and properties names === JS: 0: [
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 ===
这意味着什么?为什么我没有得到标准对象或数组输出
请注意,我无法使用chrome/firefox开发工具,因为我是从Telerik NativeScript框架编写代码的
另外,我从Angular 2中内置组件的“代码隐藏”调用此代码
这是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>
这是explorer\u item\u 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))
}
}
我认为这是explorer和explorer\u item\u行组件之间的绑定问题,但我不知道为什么以及如何解决它
最后,我进入了Nativescript调试页面:因此我应该能够在Chrome的开发工具中检查它。item=“{{item}}
是Nativescript核心绑定的语法。其中Nativescript+Angular-2应该使用ng样式,意思是[item]=“item”
在ng应用程序中使用核心语法将导致返回的值类型为[object object]
,而不是您期望的值。item=“{{item}}
是NativeScript核心绑定的语法。。其中NativeScript+Angular-2应该使用ng样式,这意味着[item]=“item”
在ng应用程序中使用核心语法将导致返回的值类型为
[object object]
,而不是您期望的值。对于如何使用console.dir
格式化输出没有标准。使用console.log(JSON.stringify(myVariable))
可以获得什么输出?这和预期的一样吗?可能是myVar是JSON.Strigfiedi get[object object]
和JSON.stringify(variable)
没有关于如何使用console.dir格式化输出的标准。使用console.log(JSON.stringify(myVariable))
可以获得什么输出?这和预期的一样吗?可能是myVar是JSON.Strigfiedi get[object object]
和JSON.stringify(variable)
感谢您给出了准确的答案。我会在回家后贴上我的电脑来确认这一点。谢谢。它按预期工作。您是否有指向解释此概念的NativeScript文档的指针?在这里您可以找到有关NativeScript+Angular-2应用程序中数据绑定的文章-文档分为NativeScript Core和NativeScript Angular。。很快,我们将在文档部分有更好的用户界面,部门将非常感谢您。我来看看。谢谢你的准确回答。我会在回家后贴上我的电脑来确认这一点。谢谢。它按预期工作。您是否有指向解释此概念的NativeScript文档的指针?在这里您可以找到有关NativeScript+Angular-2应用程序中数据绑定的文章-文档分为NativeScript Core和NativeScript Angular。。很快,我们将在文档部分有更好的用户界面,部门将非常感谢您。我来看看。
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;
}
}
}
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))
}
}