奇怪的javascript变量转储
Strange javascript variable dumping
当调用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中构建的组件的"code - behind"中调用这些代码的。
这是浏览器组件的html, explorer.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_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>
这是exploreritem类:
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;
}
}
}
这是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))
}
}
我认为这是浏览器和explorer_item_line组件之间的绑定问题,但我不知道为什么以及如何解决它。
最后,我登陆了原生脚本调试页面:所以我应该能够在Chrome的开发人员工具中检查它。
item="{{item}}
是NativeScript核心绑定的语法。其中,NativeScript+Angular-2应该使用ng样式,即[item]="item"
在ng-app中使用核心语法将导致返回的值为[object Object]
类型,而不是您期望的值。
相关文章:
- console.log级别很少=错误转储
- 将JSON漂亮地转储到文本
- Javascript:全局变量转到“窗口”或“全局”,但全局函数不会.全球 FN 去哪儿了
- 如何清空变量/将变量转回未定义
- JQuery 快速转储对象的成员
- 从粘贴的 JSON 转储动态自动完成表单
- 故障转储缺少 NodeWebKit
- 使用 JavaScript 将大数据转储到 csv 文件
- 当我按空格键时,它会转储整个数据库
- Meteor:从服务器调用相互依赖的外部 API 并将数据转储到 db
- 将 Chrome 开发控制台转储到文本文件
- React+Redux.执行容器和转储组件中定义的所有方法/操作
- 转储chartjs数据中缺少的日期
- 我可以将 HTML 文本转储到变量中吗?
- 如何“;转储”;使用LinkedBrush插件为mpld3选择的点
- 通量:顶层视图不应该是“;转储”;(不要从存储中获取数据)
- 使用javascript编译html并将其转储到文件中
- 出现在变量转储中的JavaScript函数
- 奇怪的javascript变量转储
- 将多维数组的内容转储到一个新的JSON变量中