Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
542 views
in Technique[技术] by (71.8m points)

javascript - 有角度的。 从浏览器控制台复制完整对象,JSON.stringify无法正常工作(Angular. Copy full object from browser console, JSON.stringify not working as desired)

I need to analyze the object created by Angular in the blur event.(我需要在模糊事件中分析Angular创建的对象。)

I've logged it in the console but the object is rather big and it's hard to follow, as the properties aren't directly visible and I have to click each one to know the contents.(我已将其记录在控制台中,但该对象相当大且很难遵循,因为这些属性不是直接可见的,因此我必须单击每个对象才能知道其内容。)
FocusEvent {isTrusted: true, relatedTarget: null, view: Window, detail: 0, sourceCapabilities: InputDeviceCapabilities, …}
bubbles: false
cancelBubble: false
cancelable: false
composed: true
currentTarget: null
defaultPrevented: false
detail: 0
eventPhase: 0
isTrusted: true
path: (14) [input.table-cell, td, tr, tbody.ui-table-tbody, table, div.ui-table-wrapper, div.ui-table.ui-widget, p-table, app-table-test, app-root, body, html, document, Window]
relatedTarget: null
returnValue: true
sourceCapabilities: InputDeviceCapabilities {firesTouchEvents: false}
srcElement: input.table-cell
target: input.table-cell
timeStamp: 6538.540000008652
type: "blur"
view: Window {parent: Window, postMessage: ?, blur: ?, focus: ?, close: ?, …}
which: 0
__proto__: FocusEvent

To this end, I've used JSON.stringify to turn it into a string that I can copy into the clipboard (and then a text editor), but its only output is an object with just one property , namely, it shows {isTrusted: true} .(为此,我使用JSON.stringify将其转换为可以复制到剪贴板(然后是文本编辑器)的字符串,但是它的唯一输出是仅具有一个属性的对象 ,即,它显示{isTrusted: true} 。)

That's it.(而已。)

I've read that stringify only shows own properties, and I wonder if there is a way I can make it print everything.(我读过stringify只显示自己的属性,不知道是否有一种方法可以使它打印所有内容。)

  ask by JD Gamboa translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Just try these simple steps :(只需尝试以下简单步骤:)

  • Evaluate expression/variable you want to copy, for eg: you want to copy "FocusEventObject", then hover over "FocusEventObject" from your code source and hit ctrl + shift + e, or if you have printed in console.log(), then follow next steps(评估要复制的表达式/变量,例如:您要复制“ FocusEventObject”,然后将其悬停在代码源中的“ FocusEventObject”上,并按ctrl + shift + e,或者如果已在console.log()中打印,然后按照下一步)
  • This evaluated expression will gets printed in the console, then right-click on the object and select "Store as global variable", and follow the next step(评估后的表达式将被打印在控制台中,然后右键单击该对象并选择“存储为全局变量”,然后执行下一步)
  • After clicking on "Store as global variable", it will create a "temp1" variable and prints in console, then run this command, "copy(temp1)".(单击“存储为全局变量”后,它将创建一个“ temp1”变量并在控制台中打印,然后运行此命令“ copy(temp1)”。) In this way, you can copy the entire object to the clipboard, and use anywhere in system.(这样,您可以将整个对象复制到剪贴板,并在系统中的任何位置使用。)

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

57.0k users

...