仿互站小程序
This commit is contained in:
34
vant/badge-group/index.js
Normal file
34
vant/badge-group/index.js
Normal file
@@ -0,0 +1,34 @@
|
||||
(0, require("../common/component").VantComponent)({
|
||||
relation: {
|
||||
name: "badge",
|
||||
type: "descendant",
|
||||
linked: function(e) {
|
||||
this.badges.push(e), this.setActive(this.data.active);
|
||||
},
|
||||
unlinked: function(e) {
|
||||
this.badges = this.badges.filter(function(t) {
|
||||
return t !== e;
|
||||
}), this.setActive(this.data.active);
|
||||
}
|
||||
},
|
||||
props: {
|
||||
active: {
|
||||
type: Number,
|
||||
value: 0,
|
||||
observer: "setActive"
|
||||
}
|
||||
},
|
||||
beforeCreate: function() {
|
||||
this.badges = [], this.currentActive = -1;
|
||||
},
|
||||
methods: {
|
||||
setActive: function(e) {
|
||||
var t = this.badges, i = this.currentActive;
|
||||
if (!t.length) return Promise.resolve();
|
||||
this.currentActive = e;
|
||||
var s = [];
|
||||
return i !== e && t[i] && s.push(t[i].setActive(!1)), t[e] && s.push(t[e].setActive(!0)),
|
||||
Promise.all(s);
|
||||
}
|
||||
}
|
||||
});
|
13
vant/badge-group/index.json
Normal file
13
vant/badge-group/index.json
Normal file
@@ -0,0 +1,13 @@
|
||||
{
|
||||
"component": true,
|
||||
"usingComponents": {
|
||||
"forview": "/utils/forview/index",
|
||||
"van-loading": "/vant/loading/index",
|
||||
"van-dialog": "/vant/dialog/index",
|
||||
"van-button": "/vant/button/index",
|
||||
"van-icon": "/vant/icon/index",
|
||||
"van-popup": "/vant/popup/index",
|
||||
"van-tab": "/vant/tab/index",
|
||||
"van-tabs": "/vant/tabs/index"
|
||||
}
|
||||
}
|
3
vant/badge-group/index.wxml
Normal file
3
vant/badge-group/index.wxml
Normal file
@@ -0,0 +1,3 @@
|
||||
<view class="van-badge-group van-hairline--top-bottom custom-class">
|
||||
<slot></slot>
|
||||
</view>
|
5
vant/badge-group/index.wxss
Normal file
5
vant/badge-group/index.wxss
Normal file
@@ -0,0 +1,5 @@
|
||||
@import "../area/index.wxss";
|
||||
|
||||
.van-badge-group {
|
||||
width: 85px;
|
||||
}
|
Reference in New Issue
Block a user