使用for中创建此动态

时间:2017-10-22 18:02:24

标签: javascript

我使用名为" Routie"的路由器脚本。这样做:

$ jq -M '.results |= {b}' <<< '{"success":true, "results":{"a": "…", "b": "…", "c": "…"}}'
{
  "success": true,
  "results": {
    "b": "…"
  }
}

之后,我有一个json文件,

routie = ({
   "": function(){
      //code after routing
   },
   "home": function(){
      //code after routing
   },
   "about": function(){
      //code after routing
   }
});

通过此代码提取

{
    "links" : [
        {"page" : "Home", "url" : "home", "file" : "template_1.html"},
        {"page" : "About", "url" : "about", "file" : "template_2.html"},
        {"page" : "Contact", "url" : "contact", "file" : "template_3.html"},
        {"page" : "Categories", "url" : "categories", "file" : "template_4.html"}
    ]
}

我将根据我的json文件传递我的路线,使用路线信息制作一个dinamycally对象:

readTextFile("menu.json", function(text){
  var data = JSON.parse(text);
}

但它不起作用:/

任何人都知道我做错了什么?

0 个答案:

没有答案