这个组件中使用了elementui的两个图标
组件Js:
Vue.component('work-container', {
props: ['height'],
data: function () {
return {
isCollapse: false
}
},
computed: {
topbarcssobj: function () {
var obj = { padding: '3px' };
if (this.isCollapse) {
obj.display = 'none';
}
else {
obj.display = 'block';
if (this.height) {
obj.height = this.height + 'px';
} else {
obj.height = '40px';
}
}
return obj;
},
btniconcssobj: function () {
return this.isCollapse ? 'el-icon-caret-bottom' : 'el-icon-caret-top';
},
strview: function () {
return this.isCollapse ? '显示' : '隐藏';
}
},
methods: {
togglebar: function () {
this.isCollapse = !this.isCollapse;
}
},
template: '<el-container>\
<el-header v-bind:style="topbarcssobj">\
<slot name="tbar"></slot>\
</el-header>\
<el-main>\
<div style="margin:3px;">\
<div style="float:left;margin-right:10px;cursor:pointer;color: #d3dce6;display:none;" v-on:click="togglebar">\
<i v-bind:class="btniconcssobj">{{strview}}查询条件</i>\
</div>\
<div>\
<slot name="btn"></slot>\
</div>\
</div>\
<div>\
<slot name="work"></slot>\
</div>\
</el-main>\
</el-container>'
});
调用:
<script src="~/Scripts/vue/workcontainer.js"></script>
<work-container v-bind:height="80">
<template v-slot:tbar>
<spec-combo v-on:selectspec="setSpec"></spec-combo>
<ban-input v-on:selectban="setBan"></ban-input>
<grade-input v-on:selectban="setGrade"></grade-input>
</template>
<template v-slot:work>
{{spec}}
{{ban}}
{{grade}}
</template>
</work-container>