【问题标题】:Get a JSON object key as a link获取 JSON 对象键作为链接
【发布时间】:2018-12-17 06:17:04
【问题描述】:

我正在尝试将 json 作为 json 格式,但将键作为链接。

这样,每当我点击链接时,我都应该将输出作为带有索引的键

例子

[
  {
    "userId": 1,
    "id": 1,
    "title": "sunt aut facere repellat provident occaecati excepturi optio 
    reprehenderit",
    "body": "quia et suscipit\nsuscipit recusandae consequuntur expedita et 
    cum\nreprehenderit molestiae ut ut quas totam\nnostrum rerum est autem sunt 
    rem eveniet architecto"
    },
    {
    "userId": 1,
    "id": 2,
    "title": "qui est esse",
    "body": "est rerum tempore vitae\nsequi sint nihil reprehenderit dolor 
     beatae ea dolores neque\nfugiat blanditiis voluptate porro vel nihil 
     molestiae ut reiciendis\nqui aperiam non debitis possimus qui neque nisi 
     nulla"
     }
     ]

当我点击 id 为 1 的 userId 时,我应该将 otput 设为 0.userId

谁能给我建议一种方法来解决我的问题。

【问题讨论】:

    标签: javascript vue.js


    【解决方案1】:

    好的,如果你不使用jquery 试试这个

    url = Object.keys(jsonObject).map(function(someparameter) {
        return encodeURIComponent(someparameter) + '=' + encodeURIComponent(jsonBoject[someparameter])
    }).join('&')
    

    【讨论】:

      【解决方案2】:

      我认为你看起来像这样https://json-ld.org/

      【讨论】:

        猜你喜欢
        • 2010-12-02
        • 1970-01-01
        • 2014-07-12
        • 1970-01-01
        • 1970-01-01
        • 2013-12-17
        • 2012-12-04
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多