如何从js中的对象获取值?

时间:2018-10-02 09:44:41

标签: javascript

我在JS中有对象

File​
accepted: true​
dataURL: "data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAASABIAAD/4Qh8RXhpZgAATU0AKgAAAAgADAEPAAIAAAAGAAAAngEQAAIAAAAOAAAApAESAAMAAAABAAYAAAEaAAUAAAABAAAAsgEbAAUAAAABAAAAugEoAAMAAAABAAIAAAExAAIAAAAFAAAAwgEyAAIAAAAUAAAAyAFCAAQAAAABAAACAAFDAAQAAAABAAACAIdpAAQAAAABAAAA3IglAAQAAAABAAAHPgAAAABBcHBsZQBpUGhvbmUgOCBQbHVzAAAAAEgAAAABAAAASAAAAAExMi4wAAAyMDE4OjA5OjIxIDE0OjI3OjU1AAAfgpoABQAAAAEAAAJWgp0ABQAAAAEAAAJeiCIAAwAAAAEAAgAAiCcAAwAAAAEAUAAAkAAABwAAAAQwMjIxkAMAAgAAABQAAAJmkAQAAgAAABQAAAJ6kQEABwAAAAQBAgMAkgEACgAAAAEAAAKOkgIABQAAAAEAAAKWkgMACgAAAAEAAAKekgQACgAAAAEAAAKmkgcAAwAAAAEABQAAkgkAAwAAAAEAEAAAkgoABQAAAAEAAAKukhQAAwAAAAQAAAK2knwABwAABC4AAAK+kpEAAgAAAAQ4NDIAkpIAAgAAAAQ4NDIAoAAABwAAAAQwMTAwoAIABAAAAAEAAA/AoAMABAAAAAEAAAvQohcAAwAAAAEAAgAAowEABwAAAAEBAAAApAIAAwAAAAEAAAAApAMAAwAAAAEAAAAApAUAAwAAAAEAHAAApAYAAwAAAAEAAAAApDIABQAAAAQAAAbspDMAAgAAAAYAAAcMpDQAAgAAACwAAAcSAAAAAAAAAAEAAAAPAAAACQAAAAUyMDE4OjA5OjIxIDE0OjI3OjU1ADIwMTg6MDk6MjEgMTQ6Mjc6NTUAAAASbAAABLcAAAhvAAAE+QAAEhsAAAq6AAAAAAAAAAEAAAGPAAAAZAffBecIqQUyQ…"​
height: 3024​
lastModified: 1537604334019​
name: "%6qdJvzqS1OTnJATyo8lZQ.jpg"​
previewElement: <div class="dz-preview dz-processing dz-success dz-complete dz-image-preview">​
previewTemplate: <div class="dz-preview dz-processing dz-success dz-complete dz-image-preview">​
processing: true​
size: 1636910​
status: "success"
type: "image/jpeg"​
upload: Object { uuid: "af40c7d8-7d46-49f3-8770-1d6998a8485f", progress: 100, total: 1637145, … }​
webkitRelativePath: ""​width: 4032​xhr: XMLHttpRequest { readyState: 4, timeout: 30000, withCredentials: false, … }​
<prototype>: FilePrototype { name: Getter, lastModified: Getter, webkitRelativePath: Getter, … } 
SystemConfiguration:642:17

如何接受(正确或错误)和姓名?

2 个答案:

答案 0 :(得分:0)

假设对象的名称是obj。 然后,您将该属性称为

let val = obj.accepted;

答案 1 :(得分:0)

#include <iostream> #include <cmath> using namespace std; int factorial(int n) { if (n <= 1) { return 1; } else { return n * factorial(n-1); } } int main() { int x = 3; cout << x << endl; factorial(x); cout << x; return 0; }

现在,您可以通过以下方式访问myFile的任何属性。

var myFile = new File([""], "filename");