簡體   English   中英

如何獲得 object 的屬性?

[英]how can i get the properties of a object?

如何獲得我的 object 的屬性?

您好,我正在嘗試使用 id 數組獲取屬性,但我的控制台說未定義

我試試這個

console.log(data.entry.properties)

它向我展示了兩個屬性“pm:title”和“pm:taggable”,但我只想要“pm:taggable”和他的數組

我嘗試類似的東西

console.log(data.entry.properties["pm:taggable"])

但它告訴我:未定義的屬性(讀取'cm:taggable')

我想在控制台中只顯示 ids 'cm:taggable' 的數組

data: {
    entry: {
      isFile: true,
      createdByUser: [Object],
      content: [Object],
      aspectNames: [Array],
      isFolder: false,
      modifiedByUser: [Object],
      name: 'Cine',
      properties: [Object]
    }
  }

這些屬性有一個 object

"properties": {
            "pm:title": "Scary movie",
            "pm:taggable": [
                "a112a22463563-9c56-428f-a4ac-a2341as2a",
                "2545ds467-62e5-448d-a062-34sf466dfs",
                "a3af33-2b8d-40c3-98c3-3awfsa356a"
            ],
            "cm:description": "Description"
        }

奇怪,它對我有用。 也許您錯誤地引用了父元素,跳過了變量名?

 const resourceData = { "data": { "entry": { "id": "string", "name": "string", "nodeType": "string", "isFolder": true, "isFile": true, "isLocked": false, "modifiedAt": "2022-09-23T18:25:21.236Z", "modifiedByUser": { "displayName": "string", "id": "string" }, "aspectNames": [ "string" ], "properties": {}, "allowableOperations": [ "string" ], "properties": { "pm:title": "title", "pm:taggable": [ "a112a22463563-9c56-428f-a4ac-a2341as2a", "2545ds467-62e5-448d-a062-34sf466dfs", "a3af33-2b8d-40c3-98c3-3awfsa356a" ], "cm:description": "Description" } } } } console.log(resourceData.data.entry.properties['pm:title']) console.log(resourceData.data.entry.properties['pm:taggable']) console.log(resourceData.data.entry.properties['cm:description'])

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM