js或者jq实现二级联动,select实现,要求进入页面默认初始化状态。

circle
  • 4.7k

这是数据格式,求助。parent_id为零的为父级。
[
{
"id": 1,
"title": "餐饮美食",
"parent_id": 0,
"sort": 1
},
{
"id": 2,
"title": "丽人美发",
"parent_id": 0,
"sort": 1
},
{
"id": 3,
"title": "KTV酒店",
"parent_id": 0,
"sort": 1
},
{
"id": 4,
"title": "啊三大的",
"parent_id": 0,
"sort": 1
},
{
"id": 5,
"title": "休闲娱乐",
"parent_id": 0,
"sort": 1
},
{
"id": 6,
"title": "自助火锅",
"parent_id": 0,
"sort": 1
},
{
"id": 7,
"title": "玩",
"parent_id": 0,
"sort": 1
},
{
"id": 8,
"title": "餐饮吧",
"parent_id": 1,
"sort": 2
},
{
"id": 9,
"title": "剪发吧·",
"parent_id": 2,
"sort": 2
},
{
"id": 10,
"title": "ktv哦",
"parent_id": 3,
"sort": 2
},
{
"id": 11,
"title": "啊飒飒色彩哦",
"parent_id": 4,
"sort": 2
},
{
"id": 12,
"title": "休闲养生",
"parent_id": 5,
"sort": 2
},
{
"id": 13,
"title": "火锅·海底捞",
"parent_id": 6,
"sort": 2
},
{
"id": 14,
"title": "电影",
"parent_id": 7,
"sort": 2
},
{
"id": 15,
"title": "美食1",
"parent_id": 1,
"sort": 0
},
{
"id": 16,
"title": "美发2",
"parent_id": 1,
"sort": 0
},
{
"id": 17,
"title": "美发3",
"parent_id": 1,
"sort": 0
},
{
"id": 18,
"title": "美发4",
"parent_id": 1,
"sort": 0
},
{
"id": 19,
"title": "美发5",
"parent_id": 2,
"sort": 0
},
{
"id": 20,
"title": "美发6",
"parent_id": 2,
"sort": 0
},
{
"id": 21,
"title": "美发7",
"parent_id": 2,
"sort": 0
},
{
"id": 23,
"title": "333",
"parent_id": 1,
"sort": 0
},
{
"id": 24,
"title": "xlh2",
"parent_id": 1,
"sort": 0
}
]

回复
阅读 3.5k
2 个回答
✓ 已被采纳

你要表达什么,想要什么效果

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
你知道吗?

宣传栏