mirror of
https://gitee.com/vant-contrib/vant-weapp.git
synced 2025-04-06 03:58:05 +08:00
feat(Icon): remove wxs (#1942)
This commit is contained in:
parent
b685dd73d4
commit
00c090ad07
@ -3,13 +3,20 @@ import { VantComponent } from '../common/component';
|
|||||||
VantComponent({
|
VantComponent({
|
||||||
props: {
|
props: {
|
||||||
info: null,
|
info: null,
|
||||||
name: String,
|
|
||||||
size: String,
|
size: String,
|
||||||
color: String,
|
color: String,
|
||||||
customStyle: String,
|
customStyle: String,
|
||||||
classPrefix: {
|
classPrefix: {
|
||||||
type: String,
|
type: String,
|
||||||
value: 'van-icon'
|
value: 'van-icon'
|
||||||
|
},
|
||||||
|
name: {
|
||||||
|
type: String,
|
||||||
|
observer(val) {
|
||||||
|
this.setData({
|
||||||
|
isImageName: val.indexOf('/') !== -1
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
<wxs src="../wxs/utils.wxs" module="utils" />
|
|
||||||
|
|
||||||
<view
|
<view
|
||||||
class="custom-class {{ classPrefix }} {{ utils.isSrc(name) ? 'van-icon--image' : classPrefix + '-' + name }}"
|
class="custom-class {{ classPrefix }} {{ isImageName ? 'van-icon--image' : classPrefix + '-' + name }}"
|
||||||
style="{{ color ? 'color: ' + color + ';' : '' }}{{ size ? 'font-size: ' + size + ';' : '' }}{{ customStyle }}"
|
style="{{ color ? 'color: ' + color + ';' : '' }}{{ size ? 'font-size: ' + size + ';' : '' }}{{ customStyle }}"
|
||||||
bind:tap="onClick"
|
bind:tap="onClick"
|
||||||
>
|
>
|
||||||
@ -11,7 +9,7 @@
|
|||||||
custom-class="van-icon__info"
|
custom-class="van-icon__info"
|
||||||
/>
|
/>
|
||||||
<image
|
<image
|
||||||
wx:if="{{ utils.isSrc(name) }}"
|
wx:if="{{ isImageName }}"
|
||||||
src="{{ name }}"
|
src="{{ name }}"
|
||||||
mode="aspectFit"
|
mode="aspectFit"
|
||||||
class="van-icon__image"
|
class="van-icon__image"
|
||||||
|
@ -1,12 +1,7 @@
|
|||||||
var bem = require('./bem.wxs').bem;
|
var bem = require('./bem.wxs').bem;
|
||||||
var memoize = require('./memoize.wxs').memoize;
|
var memoize = require('./memoize.wxs').memoize;
|
||||||
|
|
||||||
function isSrc(url) {
|
|
||||||
return url.indexOf('http') === 0 || url.indexOf('data:image') === 0 || url.indexOf('//') === 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
bem: memoize(bem),
|
bem: memoize(bem),
|
||||||
isSrc: isSrc,
|
|
||||||
memoize: memoize
|
memoize: memoize
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user