Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
U
uview-ui
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
李晖
uview-ui
Commits
ca6f9033
Commit
ca6f9033
authored
Apr 23, 2020
by
王博文
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
增加数组类型
parent
8629de99
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
166 additions
and
157 deletions
+166
-157
u-badge.vue
uview/components/u-badge/u-badge.vue
+166
-157
No files found.
uview/components/u-badge/u-badge.vue
View file @
ca6f9033
<
template
>
<
template
>
<view
v-if=
"show"
class=
"u-badge-box"
:class=
"[isDot ? 'u-badge-dot' : 'u-badge', size == 'mini' ? 'u-badge-mini' : '']"
:style=
"[
{
<view
v-if=
"show"
class=
"u-badge-box"
:class=
"[isDot ? 'u-badge-dot' : 'u-badge', size == 'mini' ? 'u-badge-mini' : '']"
:style=
"[
{
top: offset[0] + 'rpx',
top: offset[0] + 'rpx',
right: offset[1] + 'rpx',
right: offset[1] + 'rpx',
fontSize: fontSize + 'rpx',
fontSize: fontSize + 'rpx',
position: absolute ? 'absolute' : 'static',
position: absolute ? 'absolute' : 'static',
color: color,
color: color,
backgroundColor: backgroundColor
backgroundColor: backgroundColor
}, boxStyle]">
}, boxStyle]"
{{
showText
}}
>
{{
showText
}}
</view>
</view>
</
template
>
</
template
>
<
script
>
<
script
>
export
default
{
export
default
{
props
:
{
props
:
{
// primary,warning,success,error,info
// primary,warning,success,error,info
type
:
{
type
:
{
type
:
String
,
type
:
String
,
default
:
'
error
'
default
:
"
error
"
},
},
// default, mini
// default, mini
size
:
{
size
:
{
type
:
String
,
type
:
String
,
default
:
'
default
'
default
:
"
default
"
},
},
//是否是圆点
//是否是圆点
isDot
:
{
isDot
:
{
...
@@ -31,7 +34,7 @@
...
@@ -31,7 +34,7 @@
},
},
// 显示的数值内容
// 显示的数值内容
count
:
{
count
:
{
type
:
[
Number
,
String
],
type
:
[
Number
,
String
,
Array
]
},
},
// 展示封顶的数字值
// 展示封顶的数字值
overflowCount
:
{
overflowCount
:
{
...
@@ -47,7 +50,7 @@
...
@@ -47,7 +50,7 @@
offset
:
{
offset
:
{
type
:
Array
,
type
:
Array
,
default
:
()
=>
{
default
:
()
=>
{
return
[
20
,
20
]
return
[
20
,
20
];
}
}
},
},
// 是否开启绝对定位,开启了offset才会起作用
// 是否开启绝对定位,开启了offset才会起作用
...
@@ -58,17 +61,17 @@
...
@@ -58,17 +61,17 @@
// 字体大小
// 字体大小
fontSize
:
{
fontSize
:
{
type
:
[
String
,
Number
],
type
:
[
String
,
Number
],
default
:
'
24
'
default
:
"
24
"
},
},
// 字体演示
// 字体演示
color
:
{
color
:
{
type
:
String
,
type
:
String
,
default
:
'
#ffffff
'
default
:
"
#ffffff
"
},
},
// badge的背景颜色
// badge的背景颜色
bgColor
:
{
bgColor
:
{
type
:
String
,
type
:
String
,
default
:
''
default
:
""
},
},
// 是否让badge组件的中心点和父组件右上角重合,配置的话,offset将会失效
// 是否让badge组件的中心点和父组件右上角重合,配置的话,offset将会失效
isCenter
:
{
isCenter
:
{
...
@@ -80,30 +83,36 @@
...
@@ -80,30 +83,36 @@
// 是否将badge中心与父组件右上角重合
// 是否将badge中心与父组件右上角重合
boxStyle
()
{
boxStyle
()
{
let
style
=
{};
let
style
=
{};
if
(
this
.
isCenter
)
{
if
(
this
.
isCenter
)
{
style
.
top
=
0
;
style
.
top
=
0
;
style
.
right
=
0
;
style
.
right
=
0
;
// Y轴-50%,意味着badge向上移动了badge自身高度一半,X轴50%,意味着向右移动了自身宽度一半
// Y轴-50%,意味着badge向上移动了badge自身高度一半,X轴50%,意味着向右移动了自身宽度一半
style
.
transform
=
"
translateY(-50%) translateX(50%)
"
;
style
.
transform
=
"
translateY(-50%) translateX(50%)
"
;
}
else
{
}
else
{
style
.
top
=
this
.
offset
[
0
]
+
'
rpx
'
;
style
.
top
=
this
.
offset
[
0
]
+
"
rpx
"
;
style
.
right
=
this
.
offset
[
1
]
+
'
rpx
'
;
style
.
right
=
this
.
offset
[
1
]
+
"
rpx
"
;
style
.
transform
=
"
translateY(0) translateX(0)
"
;
style
.
transform
=
"
translateY(0) translateX(0)
"
;
}
}
return
style
;
return
style
;
},
},
// isDot类型时,不显示文字
// isDot类型时,不显示文字
showText
()
{
showText
()
{
if
(
this
.
isDot
)
return
''
;
if
(
this
.
isDot
)
return
""
;
else
{
console
.
log
(
this
.
count
);
if
(
this
.
count
>
this
.
overflowCount
)
return
`
${
this
.
overflowCount
}
+`
;
if
(
Array
.
isArray
(
this
.
count
))
{
else
return
this
.
count
;
if
(
this
.
count
.
length
>
this
.
overflowCount
)
{
return
`
${
this
.
overflowCount
}
+`
;
}
else
return
this
.
count
.
length
;
}
else
{
if
(
this
.
count
>
this
.
overflowCount
)
{
return
`
${
this
.
overflowCount
}
+`
;
}
else
return
this
.
count
;
}
}
},
},
// 是否显示组件
// 是否显示组件
show
()
{
show
()
{
// 如果count的值为0,并且showZero设置为false,不显示组件
// 如果count的值为0,并且showZero设置为false,不显示组件
if
(
this
.
count
==
0
&&
this
.
showZero
==
false
)
return
false
;
if
(
this
.
count
==
0
&&
this
.
showZero
==
false
)
return
false
;
else
return
true
;
else
return
true
;
},
},
// 获取背景颜色,如果定义了bgColor参数,就放弃type主题色
// 获取背景颜色,如果定义了bgColor参数,就放弃type主题色
...
@@ -111,61 +120,61 @@
...
@@ -111,61 +120,61 @@
return
this
.
bgColor
?
this
.
bgColor
:
this
.
$u
.
color
[
this
.
type
];
return
this
.
bgColor
?
this
.
bgColor
:
this
.
$u
.
color
[
this
.
type
];
}
}
}
}
}
};
</
script
>
</
script
>
<
style
lang=
"scss"
scoped
>
<
style
lang=
"scss"
scoped
>
.u-badge-box
{
.u-badge-box
{
display
:
inline-flex
;
display
:
inline-flex
;
justify-content
:
center
;
justify-content
:
center
;
align-items
:
center
;
align-items
:
center
;
}
}
.u-badge
{
.u-badge
{
line-height
:
24rpx
;
line-height
:
24rpx
;
padding
:
4rpx
8rpx
;
padding
:
4rpx
8rpx
;
border-radius
:
100rpx
;
border-radius
:
100rpx
;
}
}
.u-badge-dot
{
.u-badge-dot
{
height
:
16rpx
;
height
:
16rpx
;
width
:
16rpx
;
width
:
16rpx
;
border-radius
:
100rpx
;
border-radius
:
100rpx
;
line-height
:
1
;
line-height
:
1
;
}
}
.u-badge-mini
{
.u-badge-mini
{
transform
:
scale
(
0
.8
);
transform
:
scale
(
0
.8
);
transform-origin
:
center
center
;
transform-origin
:
center
center
;
}
}
// .u-primary {
// .u-primary {
// background: $u-type-primary;
// background: $u-type-primary;
// color: #fff;
// color: #fff;
// }
// }
// .u-error {
// .u-error {
// background: $u-type-error;
// background: $u-type-error;
// color: #fff;
// color: #fff;
// }
// }
// .u-warning {
// .u-warning {
// background: $u-type-warning;
// background: $u-type-warning;
// color: #fff;
// color: #fff;
// }
// }
// .u-success {
// .u-success {
// background: $u-type-success;
// background: $u-type-success;
// color: #fff;
// color: #fff;
// }
// }
// .u-black {
// .u-black {
// background: #585858;
// background: #585858;
// color: #fff;
// color: #fff;
// }
// }
.u-info
{
.u-info
{
background
:
$u-type-info
;
background
:
$u-type-info
;
color
:
#fff
;
color
:
#fff
;
}
}
</
style
>
</
style
>
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment