render(){
return (
<div><div>
)
}
<div class={'e-cell--right'} on-click={change.bind(this)}>
{
check
? <span class={'e-cell-icon'}></span>
: ''
}
</div>
ps : check 为真时的效果
<div class={'e-cell--right'} on-click={change.bind(this)}>
{
check
? <span class={'e-cell-icon'}></span>
: ''
}
</div>
render(h){
const {label, value, check, change} = this
return (
<div class={'e-cell'}>
<div class={'e-cell--content'}>
<span class={'e-cell--label'}>{label}</span>
{
this.$slots.default
? h('i', this.$slots.default)
: <div class={'e-cell--value'}>{value}</div>
}
</div>
</div>
)
},
// less
.e-cell--content{
.e-cell--label{
display: inline-block;
width: 120px;
font-size:28px;
font-family:PingFangSC-Regular;
font-weight:400;
color:rgba(51,51,51,1);
line-height:40px;
}
.e-cell--value,*{ //关于插槽样式
font-style: normal;
font-size:24px;
font-family:PingFangSC-Regular;
font-weight:400;
color:rgba(51,51,51,1);
line-height:40px;
}
}
//cell组件的样式
import './cell.less'
export default {
name:'ECell',
//允许传入的参数
props:{
label:{
type:String,
default:'T'
},
value:{
type:String,
default:'(T (共2888点,抵20元))'
}
},
data(){
return {
check:false,
}
},
//绑定一个事件, 通知是否被点击
methods:{
change(){
this.check = !this.check
this.$emit('change', {evt:this.label, select: this.check})
},
},
// render vue官方对 h 的描述 这是一个约定
render(h){
const {label, value, check, change} = this
return (
<div class={'e-cell'}>
<div class={'e-cell--content'}>
<span class={'e-cell--label'}>{label}</span>
{
this.$slots.default
? h('i', this.$slots.default)
: <div class={'e-cell--value'}>{value}</div>
}
</div>
<div class={'e-cell--right'} on-click={change.bind(this)}>
{
check
? <span class={'e-cell-icon'}></span>
: ''
}
</div>
</div>
)
},
}
//局部
import ECell from '../../lib/cell'
components:{ECell},
<ECell ref="cake"
label="T币"
:value="`(T币 (共${prouctList.cake || 0}币,抵${Number(prouctList.cake || 0) /100}元))`"
@change="handleChangeCake">
<i>{{`(T币 (共${prouctList.cake || 0}币,抵${Number(prouctList.cake || 0) /100}元))`}}</i>
</ECell>