我的 JavaScript 部分中有这段代码:
var opConfig = new Product.Options(<?php echo $this->getJsonConfig(); ?>);
PHP 调用返回了一些字符串,为了方便起见,假设字符串是abcd。所以这段代码导致:
var opConfig = new Product.Options(abcd);
现在,几行之后,我有这个代码:
this.opConfig = new Product.Options(opconfig);
该opconfig
变量具有相同的字符串abcd
,但结果不同,this.opConfig
看起来不像以前那样。那么我如何将字符串用作参数有区别吗?我错过了什么?对我来说,它应该始终是同一个电话,即:
new Product.Options(abcd)
想法?
补充: JS代码中的完整调用如下所示:
var opConfig = new Product.Options({"16":{"26":{"price":5,"oldPrice":5,"priceValue":"5.0000","type":"fixed","excludeTax":5,"includeTax":5},"28":{"price":8,"oldPrice":8,"priceValue":"8.0000","type":"fixed","excludeTax":8,"includeTax":8},"27":{"price":10,"oldPrice":10,"priceValue":"10.0000","type":"fixed","excludeTax":10,"includeTax":10}},"14":{"price":0,"oldPrice":0,"priceValue":"0.0000","type":"fixed","excludeTax":0,"includeTax":0},"15":{"price":0,"oldPrice":0,"priceValue":"0.0000","type":"fixed","excludeTax":0,"includeTax":0}});
参数作为对象到达被调用的函数,不知道为什么。以另一种方式调用它,相同的字符串似乎作为字符串到达它。有人可以帮忙吗?