Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
如何将 php 数组转换为 Javascript 对象代码?
你可以试试这个。这就是动态命名对象属性和对象值的方式。我假设您想在属性名称来自源的地方动态构建它。您所要做的就是遍历这些值
var treeData = {}; Loop Here var nameProperty = "propertyName"; var nameValue = "propertyValue"; var childProperty = "child"; var childValue = {};
试试这个。
http://jsfiddle.net/zKdMa/1/