<input type="hidden" name="data" id="data" value=‘[{"name":"北京","value":1,"children":[{"name":"北京市1","value":12,"children":[{"name":"朝阳区1","value":13,"children":[]},{"name":"朝阳区2","value":14,"children":[]},{"name":"朝阳区3","value":15,"children":[]},{"name":"朝阳区4","value":16,"children":[]}]},{"name":"北京市2","value":17,"children":[]},{"name":"北京市3","value":18,"children":[]},{"name":"北京市4","value":19,"children":[]}]},{"name":"天津","value":2,"children":[{"name":"天津市1","value":51,"children":[]}]}]‘ />[{},{}] 正确[{},{},] 转json对象是报错 (直接写数组不报错)var Jsondata = $("#data")[0].defaultValue;var jsonobj = JSON.parse(Jsondata); layui.formSelects.data(‘select15‘, ‘local‘, { arr: jsonobj, linkage: true ////开启联动模式 } );
原文地址:https://www.cnblogs.com/enych/p/9233830.html
时间: 2024-11-10 08:11:57