fix template to jsx

pull/165/head
tangjinzhou 7 years ago
parent 2b9a433db0
commit 0d7398237c

@ -1,16 +1,3 @@
<template>
<span :class="classes">
<img v-if="src" :src="src"/>
<icon v-else-if="icon" :type="icon" />
<span
v-else
ref="avatorChildren"
:class="[prefixCls+'-string']"
:style="childrenStyle">
<slot></slot>
</span>
</span>
</template>
<script> <script>
import Icon from '../icon' import Icon from '../icon'
@ -93,8 +80,20 @@ export default {
this.setScale() this.setScale()
}) })
}, },
components: { render () {
Icon, const { classes, prefixCls, src, icon, childrenStyle, $slots } = this
return (
<span class={classes}>
{src ? <img src={src}/>
: (icon ? <icon type={icon} />
: <span
ref='avatorChildren'
class={prefixCls + '-string'}
style={childrenStyle}>
{$slots.default}
</span>) }
</span>
)
}, },
} }
</script> </script>

@ -1,8 +1,3 @@
<template>
<span :class="classes" >
<slot />
</span>
</template>
<script> <script>
export default { export default {
@ -32,5 +27,12 @@ export default {
}, },
methods: { methods: {
}, },
render () {
return (
<span class={this.classes} >
{this.$slots.default}
</span>
)
},
} }
</script> </script>

@ -1,17 +1,3 @@
<template>
<label :class="classes">
<span :class="checkboxClass">
<input :name="name" type="radio" :disabled="disabled"
:class="`${prefixCls}-input`" :checked="stateChecked"
@change="handleChange"
/>
<span :class="`${prefixCls}-inner`" />
</span>
<span v-if="hasDefaultSlot">
<slot></slot>
</span>
</label>
</template>
<script> <script>
import hasProp from '../_util/props-util' import hasProp from '../_util/props-util'
export default { export default {
@ -47,9 +33,6 @@ export default {
} }
}, },
computed: { computed: {
hasDefaultSlot () {
return !!this.$slots.default
},
classes () { classes () {
const { prefixCls, disabled, stateChecked } = this const { prefixCls, disabled, stateChecked } = this
return { return {
@ -103,5 +86,22 @@ export default {
this.stateChecked = stateValue === this.value this.stateChecked = stateValue === this.value
}, },
}, },
render () {
const { classes, checkboxClass, disabled, prefixCls, stateChecked, handleChange, name, $slots } = this
return (
<label class={classes}>
<span class={checkboxClass}>
<input name={name} type='radio' disabled={disabled}
class={`${prefixCls}-input`} checked={stateChecked}
onChange={handleChange}
/>
<span class={`${prefixCls}-inner`} />
</span>
{$slots.default ? <span>
{$slots.default}
</span> : null}
</label>
)
},
} }
</script> </script>

@ -1,8 +1,3 @@
<template>
<div :class="classes" @click="handleClick">
<slot />
</div>
</template>
<script> <script>
export default { export default {
@ -34,5 +29,13 @@ export default {
this.$emit('change', !checked) this.$emit('change', !checked)
}, },
}, },
render () {
const { classes, handleClick, $slots } = this
return (
<div class={classes} onClick={handleClick}>
{$slots.default}
</div>
)
},
} }
</script> </script>

Loading…
Cancel
Save