11<template >
2- <text v-if =" text" :class =" inverted ? 'uni-badge-' + type + ' uni-badge--' + size + ' uni-badge-inverted' : 'uni-badge-' + type + ' uni-badge--' + size" class =" uni-badge" @click =" onClick()" >{{ text }}</text >
2+ <text v-if =" text" :class =" inverted ? 'uni-badge-- ' + type + ' uni-badge--' + size + ' uni-badge--' + type + '- inverted' : 'uni-badge-- ' + type + ' uni-badge--' + size" class =" uni-badge" :style = " width " @click =" onClick()" >{{ text }}</text >
33</template >
44
55<script >
1818 type: String ,
1919 default: ' '
2020 },
21- size: { // small.normal
21+ size: {
22+ // small.normal
2223 type: String ,
2324 default: ' normal'
2425 }
2526 },
27+ data () {
28+ return {
29+ width: ` display: inline-block;width: ${ this .text .length * 15 + 25 } rpx`
30+ };
31+ },
2632 methods: {
2733 onClick () {
28- this .$emit (' click' )
34+ this .$emit (' click' );
2935 }
3036 }
31- }
37+ };
3238 </script >
3339
34- <style >
35- @charset "UTF-8";
36-
40+ <style scoped>
3741 .uni-badge {
38- font-family : ' Helvetica Neue ' , Helvetica , sans-serif ;
39- box-sizing : border-box ;
40- font-size : 12 px ;
41- line-height : 1 ;
42- display : inline-block ;
43- padding : 3 px 6 px ;
42+ /* #ifndef APP-PLUS */
43+ display : flex ;
44+ /* #endif */
45+ flex-direction : row ;
46+ height : 40 rpx ;
47+ line-height : 40 rpx ;
4448 color : #333 ;
4549 border-radius : 100px ;
46- background-color : #f1f1f1
50+ background-color : #f1f1f1 ;
51+ background-color : transparent ;
52+ text-align : center ;
53+ font-family : ' Helvetica Neue' , Helvetica , sans-serif ;
54+ font-size : 12px ;
55+ padding : 0 ;
4756 }
4857
49- .uni-badge.uni-badge -inverted {
58+ .uni-badge- -inverted {
5059 padding : 0 5px 0 0 ;
60+ color : #f1f1f1 ;
61+ }
62+
63+ .uni-badge--default {
64+ color : #333 ;
65+ background-color : #f1f1f1 ;
66+ }
67+
68+ .uni-badge--default-inverted {
5169 color : #999 ;
52- background-color : transparent
70+ background-color : transparent ;
5371 }
5472
55- .uni-badge-primary {
73+ .uni-badge-- primary {
5674 color : #fff ;
57- background-color : #007aff
75+ background-color : #007aff ;
5876 }
5977
60- .uni-badge-primary.uni-badge -inverted {
78+ .uni-badge--primary -inverted {
6179 color : #007aff ;
62- background-color : transparent
80+ background-color : transparent ;
6381 }
6482
65- .uni-badge-success {
83+ .uni-badge-- success {
6684 color : #fff ;
67- background-color : #4cd964
85+ background-color : #4cd964 ;
6886 }
6987
70- .uni-badge-success.uni-badge -inverted {
88+ .uni-badge--success -inverted {
7189 color : #4cd964 ;
72- background-color : transparent
90+ background-color : transparent ;
7391 }
7492
75- .uni-badge-warning {
93+ .uni-badge-- warning {
7694 color : #fff ;
77- background-color : #f0ad4e
95+ background-color : #f0ad4e ;
7896 }
7997
80- .uni-badge-warning.uni-badge -inverted {
98+ .uni-badge--warning -inverted {
8199 color : #f0ad4e ;
82- background-color : transparent
100+ background-color : transparent ;
83101 }
84102
85- .uni-badge-error {
103+ .uni-badge-- error {
86104 color : #fff ;
87- background-color : #dd524d
105+ background-color : #dd524d ;
88106 }
89107
90- .uni-badge-error.uni-badge -inverted {
108+ .uni-badge--error -inverted {
91109 color : #dd524d ;
92- background-color : transparent
110+ background-color : transparent ;
93111 }
94112
95113 .uni-badge--small {
96- transform : scale (.8 );
97- transform-origin : center center
114+ transform : scale (0 .8 );
115+ transform-origin : center center ;
98116 }
99117 </style >
0 commit comments