feat: 添加自定义iconfont
This commit is contained in:
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"usingComponents": {},
|
||||
"component": true
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
@import '../../style/theme.less';
|
||||
@import '../../assets/font/iconfont.less';
|
||||
|
||||
.icon {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
display: inline-block;
|
||||
vertical-align: middle;
|
||||
font-size: inherit;
|
||||
color: inherit;
|
||||
|
||||
&.icon_image {
|
||||
width: @font-size-icon;
|
||||
height: @font-size-icon;
|
||||
}
|
||||
|
||||
&__image {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
Component({
|
||||
options: {
|
||||
//@ts-ignore
|
||||
styleIsolation: 'apply-shared',
|
||||
},
|
||||
properties: {
|
||||
// icon name
|
||||
name: {
|
||||
type: String,
|
||||
value: '',
|
||||
optionalTypes: [String],
|
||||
},
|
||||
// icon color
|
||||
color: {
|
||||
type: String,
|
||||
value: '',
|
||||
optionalTypes: [String],
|
||||
},
|
||||
// icon size
|
||||
size: {
|
||||
type: String,
|
||||
value: '',
|
||||
optionalTypes: [String],
|
||||
},
|
||||
// icon classPrefix
|
||||
classPrefix: {
|
||||
type: String,
|
||||
value: 'icon',
|
||||
optionalTypes: [String],
|
||||
},
|
||||
},
|
||||
externalClasses: ['ext-class'],
|
||||
data: {},
|
||||
methods: {},
|
||||
});
|
||||
@@ -0,0 +1,4 @@
|
||||
<wxs src="../wxs/base.wxs" module="Utils" />
|
||||
<view class="{{ Utils.classNames('icon iconfont ' + classPrefix, { icon_image: Utils.isUrl(name)}) }} {{ !Utils.isUrl(name) && classPrefix + '-' + name }} ext-class" style="{{size ? 'font-size: ' + size + 'rpx;' : ''}}{{color ? 'color: ' + color + ';' : ''}}{{Utils.isUrl(name) && size ? 'width: ' + size + ';height: ' + size + ';' : ''}}">
|
||||
<image wx:if="{{ Utils.isUrl(name) }}" src="{{ name }}" mode='aspectFit' class="icon__image" />
|
||||
</view>
|
||||
Reference in New Issue
Block a user