mirror of
https://github.com/youzan/vant.git
synced 2025-10-19 10:07:07 +00:00
[improvement] declare functional sfc (#2695)
This commit is contained in:
@@ -2,50 +2,49 @@ import { use } from '../utils';
|
||||
|
||||
const [sfc, bem] = use('password-input');
|
||||
|
||||
export default sfc(
|
||||
{
|
||||
props: {
|
||||
info: String,
|
||||
errorInfo: String,
|
||||
value: {
|
||||
type: String,
|
||||
default: ''
|
||||
},
|
||||
length: {
|
||||
type: Number,
|
||||
default: 6
|
||||
}
|
||||
export default sfc({
|
||||
functional: true,
|
||||
|
||||
props: {
|
||||
info: String,
|
||||
errorInfo: String,
|
||||
value: {
|
||||
type: String,
|
||||
default: ''
|
||||
},
|
||||
|
||||
render(h, context) {
|
||||
const { props, listeners } = context;
|
||||
const info = props.errorInfo || props.info;
|
||||
|
||||
const Points = [];
|
||||
for (let i = 0; i < props.length; i++) {
|
||||
Points.push(
|
||||
<li class="van-hairline">
|
||||
<i style={{ visibility: props.value[i] ? 'visible' : 'hidden' }} />
|
||||
</li>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<div class={bem()}>
|
||||
<ul
|
||||
class={[bem('security'), 'van-hairline--surround']}
|
||||
onTouchstart={event => {
|
||||
event.stopPropagation();
|
||||
listeners.focus && listeners.focus();
|
||||
}}
|
||||
{...context.data}
|
||||
>
|
||||
{Points}
|
||||
</ul>
|
||||
{info && <div class={bem(props.errorInfo ? 'error-info' : 'info')}>{info}</div>}
|
||||
</div>
|
||||
);
|
||||
length: {
|
||||
type: Number,
|
||||
default: 6
|
||||
}
|
||||
},
|
||||
true
|
||||
);
|
||||
|
||||
render(h, context) {
|
||||
const { props, listeners } = context;
|
||||
const info = props.errorInfo || props.info;
|
||||
|
||||
const Points = [];
|
||||
for (let i = 0; i < props.length; i++) {
|
||||
Points.push(
|
||||
<li class="van-hairline">
|
||||
<i style={{ visibility: props.value[i] ? 'visible' : 'hidden' }} />
|
||||
</li>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<div class={bem()}>
|
||||
<ul
|
||||
class={[bem('security'), 'van-hairline--surround']}
|
||||
onTouchstart={event => {
|
||||
event.stopPropagation();
|
||||
listeners.focus && listeners.focus();
|
||||
}}
|
||||
{...context.data}
|
||||
>
|
||||
{Points}
|
||||
</ul>
|
||||
{info && <div class={bem(props.errorInfo ? 'error-info' : 'info')}>{info}</div>}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
});
|
||||
|
Reference in New Issue
Block a user