wxml中是这样写的:
<view class="panel_setting">
<view style="margin:10px auto; width:100%" class="curriculum_open">
<view >开启简历后可以被企业找到你,如果暂时不想也可以关闭</view>
</view>
<view style="margin:10px auto; width:65px">
<button class="in_default" size="mini" bindtap="Open">{{candidate.open==1?"关闭":"开启"}}</button>
</view>
</view>
wxss中是这样写的:
.panel_setting{
border: 1px #b0b0b0 solid;
border-radius: 8px;
margin: 5px;
}
.curriculum_open{
font-size: 13px;
text-align:center;
}
.button {
color: white;
background-color: #5dd5c8;
border: none;
}
js中是这样写的(当然这个里面要跟你的实际情况进行调整,不能直接粘贴复制哦)
Open:function(){
var candidate = that.data.candidate;
if(candidate.open == 0){
candidate.open = 1;
}else{
candidate.open = 0;
}
web_interface.updateCandidate(candidate,function(result) {
that.setData({
candidate:candidate
});
});
},
页面写出来是这种效果,当你点击开启,按钮变为关闭状态,相反也是一样的