uni-app tree(树状) 组件

先看效果:

uni-app tree(树状) 组件_第1张图片

组件代码:






.next-tree-mask {
  position: fixed;
  top: 0rpx;
  right: 0rpx;
  bottom: 0rpx;
  left: 0rpx;
  z-index: 9998;
  background-color: rgba(0, 0, 0, 0.6);
  opacity: 0;
  transition: all 0.3s ease;
  visibility: hidden;
}
.next-tree-mask.show {
  visibility: visible;
  opacity: 1;
}
.next-tree-cnt {
  position: fixed;
  top: 0rpx;
  right: 0rpx;
  bottom: 0rpx;
  left: 0rpx;
  z-index: 9999;
  top: 160rpx;
  transition: all 0.3s ease;
  transform: translateY(100%);
}
.next-tree-cnt.show {
  transform: translateY(0);
}
.next-tree-bar {
  background-color: #fff;
  height: 72rpx;
  padding-left: 20rpx;
  padding-right: 20rpx;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-sizing: border-box;
  border-bottom-width: 1rpx !important;
  border-bottom-style: solid;
  border-bottom-color: #f5f5f5;
  font-size: 32rpx;
  color: #757575;
  line-height: 1;
}
.next-tree-bar-confirm {
  color: #f9ae3d;
}
.next-tree-view {
  position: absolute;
  top: 0rpx;
  right: 0rpx;
  bottom: 0rpx;
  left: 0rpx;
  top: 72rpx;
  background-color: #fff;
  padding-top: 20rpx;
  padding-right: 20rpx;
  padding-bottom: 20rpx;
  padding-left: 20rpx;
}
.next-tree-view-sc {
  height: 100%;
  overflow: hidden;
}
.next-tree-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 26rpx;
  color: #757575;
  line-height: 1;
  height: 0;
  opacity: 0;
  transition: 0.2s;
  position: relative;
  overflow: hidden;
}
.next-tree-item.show {
  height: 80rpx;
  opacity: 1;
}
.next-tree-item.showchild:before {
  transform: rotate(90deg);
}
.next-tree-item.border {
  border-bottom: 1rpx solid rgba(204,204,204,0.2);
}
.next-tree-item.last:before {
  opacity: 0;
}
.next-tree-icon {
  width: 26rpx;
  height: 26rpx;
  margin-right: 8rpx;
}
.next-tree-label {
  flex: 1;
  display: flex;
  align-items: center;
  height: 100%;
  line-height: 1.2;
}
.next-tree-check {
  width: 40px;
  height: 40px;
  display: flex;
  justify-content: center;
  align-items: center;
}
.next-tree-check-yes,
.next-tree-check-no {
  width: 20px;
  height: 20px;
  border-top-left-radius: 20%;
  border-top-right-radius: 20%;
  border-bottom-right-radius: 20%;
  border-bottom-left-radius: 20%;
  border-top-width: 1rpx;
  border-left-width: 1rpx;
  border-bottom-width: 1rpx;
  border-right-width: 1rpx;
  border-style: solid;
  border-color: #f9ae3d;
  display: flex;
  justify-content: center;
  align-items: center;
  box-sizing: border-box;
}
.next-tree-check-yes-b {
  border-top-left-radius: 20%;
  border-top-right-radius: 20%;
  border-bottom-right-radius: 20%;
  border-bottom-left-radius: 20%;
  background-color: #f9ae3d;
	color: #fff;
}
.next-tree-check-yes-b .icon-text {
	font-size: 14px;
	font-weight: normal;
	font-family: uicon-iconfont;
	display: flex;
	flex-direction: row;
	align-items: center;
}
.next-tree-check .radio {
  border-top-left-radius: 50%;
  border-top-right-radius: 50%;
  border-bottom-right-radius: 50%;
  border-bottom-left-radius: 50%;
}
.next-tree-check .radio .next-tree-check-yes-b {
  border-top-left-radius: 50%;
  border-top-right-radius: 50%;
  border-bottom-right-radius: 50%;
  border-bottom-left-radius: 50%;
}
.hover-c {
  opacity: 0.6;
}

 参数配置:

dataList Array [] 数据源
idKey String id 显示的主键key值
nameKey String name 显示的名字key值
phoneKey String phone 显示的电话key值
imgKey String img 显示的头像key值
radius Number 4rpx 头像圆角(rpx、px、%)
showAvatar Boolean true 是否显示头像
isInterlock Boolean false 是否双向联动
事件名 说明 类型 回调参数
itemclick 菜单项item点击事件 emit Object

 页面使用:




import nextTree from '../components/next-tree/next-tree.vue'
components: {
	nextTree
},
	





onconfirm(list) {
	console.log('选中项的数量列表list:', list)	
},

你可能感兴趣的:(uni-app)