perf(loading): use wxs (#3892)

This commit is contained in:
rex 2020-12-22 20:45:52 +08:00 committed by GitHub
parent 7df96aeb5d
commit 7378398da6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 26 additions and 3 deletions

View File

@ -1,9 +1,10 @@
<wxs src="../wxs/utils.wxs" module="utils" />
<wxs src="./index.wxs" module="computed" />
<view class="custom-class van-loading {{ vertical ? 'van-loading--vertical' : '' }}">
<view class="custom-class {{ utils.bem('loading', { vertical }) }}">
<view
class="van-loading__spinner van-loading__spinner--{{ type }}"
style="color: {{ color }}; width: {{ utils.addUnit(size) }}; height: {{ utils.addUnit(size) }}"
style="{{ computed.spinnerStyle({ color, size }) }}"
>
<view
wx:if="{{ type === 'spinner' }}"
@ -12,7 +13,7 @@
class="van-loading__dot"
/>
</view>
<view class="van-loading__text" style="font-size: {{ utils.addUnit(textSize) }};">
<view class="van-loading__text" style="{{ computed.textStyle({ textSize }) }}">
<slot />
</view>
</view>

View File

@ -0,0 +1,22 @@
/* eslint-disable */
var style = require('../wxs/style.wxs');
var addUnit = require('../wxs/add-unit.wxs');
function spinnerStyle(data) {
return style({
color: data.color,
width: addUnit(data.size),
height: addUnit(data.size),
});
}
function textStyle(data) {
return style({
'font-size': addUnit(data.textSize),
});
}
module.exports = {
spinnerStyle: spinnerStyle,
textStyle: textStyle,
};