由于公司项目的需要,我需要做一个类似树形菜单的东西来显示一个多级结构,像这样的

遇到问题

问百度呀!

搜到了一篇看上去非常靠谱的:微信小程序-树形菜单替代方案(链接)
这位老铁的方案替我解决了大问题,不过似乎有一点不是很适合我的应用场景,怎么办

自己写一个咯,大方向和他一样,不过我写不出看上去那么高大上的代码,就凑合着自己用叭,Let's GO ~

效果图,图片有点小。。就凑合着看吧。。。

代码链接,
.JSON
"usingComponents": {
"path-view": "/dist/path-view/index"
}
.JS
page({
data:{
key:'deptName',
deptList:[
{ deptName : ' 名称 ' , deptId : ' ID ' , children : [ ] , userList : [ ] }
]
},
selThis(e) {
var user = e.detail.value;
}
})
.wxml
<path-view list="{{ deptList }}" rootText="单位" bind:click="selThis" title="{{ key }}"></path-view>
因为需求的缘故,只能单选,还需要做一个多选的。。啊。。敲代码好难啊。。

第一次用GitHub,有点方方的。。。继续努力学习。。
上次做的这个菜单,经理说不适应我们平时的操作习惯啥的。。

之前做的菜单,在部门那一行,我点左边可以打开面板看到部门下的人,我点右边则可以进到它的子部门,经理说这个不符合我们的操作习惯,就我点一行,只能触发一种操作,还有在选人的时候, 必须点文字或者点单选那个,有点困难,建议都增加到整个横条上触发,还有确定和取消按钮,取消按钮完全可以不要,就很反人类

改!!!!


还有就是之前做的是弹出窗口的模式,现在换成选人的时候跳到新的页面,那怎么把选到到人返回给之前的页面呢

var pages = getCurrentPages();
var prePage = pages[pages.length - 2]; //上一个页面
这样就可以直接setData了,或者直接调用上一个页面的方法

网友评论