我想创建一个json架构对象以在json架构表单中使用。这个对象看起来像这个
this.FormValueData = {
'discountauthorizationelementsname': "userroleid,metalid,purityid,discountmodeid,categoryid,discounttypeid,discountvalue,creditpercent,creditvalue",
'discountauthorizationelementstable': "discountauthorization,discountauthorization,discountauthorization,discountauthorization,discountauthorization,discountauthorization,discountauthorization,discountauthorization,discountauthorization",
'discountauthorizationelementscolmn':"userroleid,metalid,purityid,discountmodeid,categoryid,discounttypeid,discountvalue,creditpercent,creditvalue",
'discountauthorizationelementspartabname': "discountauthorization,discountauthorization,discountauthorization,discountauthorization,discountauthorization,discountauthorization,discountauthorization,discountauthorization,discountauthorization",
'discountauthorizationviewfieldids':"110",
'viewfieldids':"110",
'moduleid':"110",
'discauthpassword':"21212121212"
};
现在我写了以下几行
let hidden_qp = {}
let elementsname = this.lowermodname.concat("elementsname");
let elementsnamevalue = "userroleid,metalid,purityid,discountmodeid,categoryid,discounttypeid,discountvalue,creditpercent,creditvalue";
let elementstable = this.lowermodname.concat("elementstable");
let elementstablevalue = "discountauthorization,discountauthorization,discountauthorization,discountauthorization,discountauthorization,discountauthorization,discountauthorization,discountauthorization,discountauthorization";
let elementscolmn = this.lowermodname.concat("elementscolmn");
let elementscolmnvalue = "userroleid,metalid,purityid,discountmodeid,categoryid,discounttypeid,discountvalue,creditpercent,creditvalue";
let elementspartabname = this.lowermodname.concat("elementspartabname");
let elementspartabnamevalue = "discountauthorization,discountauthorization,discountauthorization,discountauthorization,discountauthorization,discountauthorization,discountauthorization,discountauthorization,discountauthorization";
let viewfieldids = this.lowermodname.concat("viewfieldids");
let viewfieldidsvalue = "110";
let moduleid = "moduleid";
let moduleidvalue = "110"
let discauthpassword = "discauthpassword";
let discauthpasswordvalue = "215521512521"
hidden_qp[elementsname] = elementsnamevalue;
hidden_qp[elementstable] = elementstablevalue;
hidden_qp[elementscolmn] = elementscolmnvalue;
hidden_qp[elementspartabname] = elementspartabnamevalue;
hidden_qp[viewfieldids] = viewfieldidsvalue;
hidden_qp['viewfieldids'] = viewfieldidsvalue;
hidden_qp[moduleid] = moduleidvalue;
hidden_qp[discauthpassword] = discauthpasswordvalue;
这给了我相同的输出,但这里的键名是双引号而不是单引号,就像第一个那样,这就是在我的架构表单构建器中创建问题。 如何获取像“discountauthorizationelementsname”而不是“discountauthorizationelementsname”这样的关键值。下面是我在控制台中看到的两个变量。 !(https://imgur.com/a/ICmi1)
答案 0 :(得分:0)
我知道在做json.stringify后我再次需要做json.parse。 所以使用这一行
this.FormValueData = JSON.parse(JSON.stringify(hidden_qp));
给了我正确的输出。