mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-06 03:57:59 +08:00
[improvement] Tag and Uploader: jsx (#2627)
This commit is contained in:
parent
fab090bef9
commit
874d2f79ca
@ -1,32 +1,15 @@
|
|||||||
<template>
|
import { use } from '../utils';
|
||||||
<span
|
|
||||||
:class="[b({
|
|
||||||
mark,
|
|
||||||
plain,
|
|
||||||
round,
|
|
||||||
[size]: size
|
|
||||||
}), {
|
|
||||||
'van-hairline--surround': plain
|
|
||||||
}]"
|
|
||||||
:style="style"
|
|
||||||
>
|
|
||||||
<slot />
|
|
||||||
</span>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
import create from '../utils/create';
|
|
||||||
import { RED, BLUE, GREEN, GRAY_DARK } from '../utils/color';
|
import { RED, BLUE, GREEN, GRAY_DARK } from '../utils/color';
|
||||||
|
|
||||||
|
const [sfc, bem] = use('tag');
|
||||||
|
|
||||||
const COLOR_MAP = {
|
const COLOR_MAP = {
|
||||||
danger: RED,
|
danger: RED,
|
||||||
primary: BLUE,
|
primary: BLUE,
|
||||||
success: GREEN
|
success: GREEN
|
||||||
};
|
};
|
||||||
|
|
||||||
export default create({
|
export default sfc({
|
||||||
name: 'tag',
|
|
||||||
|
|
||||||
props: {
|
props: {
|
||||||
size: String,
|
size: String,
|
||||||
type: String,
|
type: String,
|
||||||
@ -49,6 +32,28 @@ export default create({
|
|||||||
|
|
||||||
return style;
|
return style;
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
render(h) {
|
||||||
|
const {
|
||||||
|
mark,
|
||||||
|
plain,
|
||||||
|
round,
|
||||||
|
size
|
||||||
|
} = this;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<span
|
||||||
|
class={[
|
||||||
|
bem({ mark, plain, round, [size]: size }),
|
||||||
|
{
|
||||||
|
'van-hairline--surround': plain
|
||||||
|
}
|
||||||
|
]}
|
||||||
|
style={this.style}
|
||||||
|
>
|
||||||
|
{this.$slots.default}
|
||||||
|
</span>
|
||||||
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
</script>
|
|
@ -1,24 +1,8 @@
|
|||||||
<template>
|
import { use } from '../utils';
|
||||||
<div :class="b()">
|
|
||||||
<slot />
|
|
||||||
<input
|
|
||||||
v-bind="$attrs"
|
|
||||||
ref="input"
|
|
||||||
type="file"
|
|
||||||
:class="b('input')"
|
|
||||||
:accept="accept"
|
|
||||||
:disabled="disabled"
|
|
||||||
@change="onChange"
|
|
||||||
>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script>
|
const [sfc, bem] = use('uploader');
|
||||||
import create from '../utils/create';
|
|
||||||
|
|
||||||
export default create({
|
|
||||||
name: 'uploader',
|
|
||||||
|
|
||||||
|
export default sfc({
|
||||||
inheritAttrs: false,
|
inheritAttrs: false,
|
||||||
|
|
||||||
props: {
|
props: {
|
||||||
@ -101,6 +85,27 @@ export default create({
|
|||||||
this.$refs.input && (this.$refs.input.value = '');
|
this.$refs.input && (this.$refs.input.value = '');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
render(h) {
|
||||||
|
const {
|
||||||
|
accept,
|
||||||
|
disabled
|
||||||
|
} = this;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div class={bem()}>
|
||||||
|
{this.$slots.default}
|
||||||
|
<input
|
||||||
|
{ ...{ attrs: this.$attrs } }
|
||||||
|
ref="input"
|
||||||
|
type="file"
|
||||||
|
accept={accept}
|
||||||
|
class={bem('input')}
|
||||||
|
disabled={disabled}
|
||||||
|
onChange={this.onChange}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
</script>
|
|
@ -5,13 +5,13 @@ exports[`renders demo correctly 1`] = `
|
|||||||
<div>
|
<div>
|
||||||
<div class="demo-uploader-container">
|
<div class="demo-uploader-container">
|
||||||
<div class="van-uploader"><i class="van-icon van-icon-photograph" style="color:undefined;font-size:undefined;">
|
<div class="van-uploader"><i class="van-icon van-icon-photograph" style="color:undefined;font-size:undefined;">
|
||||||
<!----></i> <input type="file" accept="image/*" class="van-uploader__input"></div>
|
<!----></i><input type="file" accept="image/*" class="van-uploader__input"></div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<div class="demo-uploader-container">
|
<div class="demo-uploader-container">
|
||||||
<div class="van-uploader"><i class="van-icon van-icon-photograph" style="color:undefined;font-size:undefined;">
|
<div class="van-uploader"><i class="van-icon van-icon-photograph" style="color:undefined;font-size:undefined;">
|
||||||
<!----></i> <input type="file" accept="image/gif, image/jpeg" multiple="multiple" class="van-uploader__input"></div>
|
<!----></i><input multiple="multiple" type="file" accept="image/gif, image/jpeg" class="van-uploader__input"></div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user