我正在用VueJs和Boostrap4创建一个组件,在其中我想通过bootstrap提供的类来获得与此类似的设计。

阅读文档,bootstrap提供了自定义的类h-75和h-25,我认为这是足够的,但我没有得到预期的结果



Vue.component('listcontent', {
  template: '<div class="w-100 h-75 bg-info">ds</div>'
})

Vue.component('datashared', {
  template: ' <div class="w-100 h-25 bg-primary">dsadsa</div>'
})


Vue.component('maincomponent', {
  template: `<div class="container h-100" >
        <div class="row h-100">
            <div class="col-md-5 h-100 border">
                <listcontent></listcontent>
                <datashared/></datashared>
            </div>
        </div>
    </div>`
})

new Vue({ el: '#app'});

html,body {
  height: 100% !important;
}

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css">
<script src="https://cdn.jsdelivr.net/npm/vue@2.5.17/dist/vue.js"></script>


<div id="app">
  <maincomponent></maincomponent>
</div>





我究竟做错了什么?如何获得理想的结果?

html - 无法在父行 bootstrap 4和VueJs中获得两行-LMLPHP

最佳答案

也为id应用程序元素添加100%的高度

html,
body,
#app {
  height: 100% !important;
}




Vue.component('listcontent', {
  template: '<div class="w-100 h-75 bg-info">ds</div>'
})

Vue.component('datashared', {
  template: ' <div class="w-100 h-25 bg-primary">dsadsa</div>'
})


Vue.component('maincomponent', {
  template: `<div class="container h-100" >
        <div class="row h-100">
            <div class="col-md-5 h-100 border">
                <listcontent></listcontent>
                <datashared/></datashared>
            </div>
        </div>
    </div>`
})

new Vue({
  el: '#app'
});

html,
body,
#app {
  height: 100% !important;
}

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css">
<script src="https://cdn.jsdelivr.net/npm/vue@2.5.17/dist/vue.js"></script>


<div id="app">
  <maincomponent></maincomponent>
</div>

关于html - 无法在父行 bootstrap 4和VueJs中获得两行,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/52177426/

10-09 15:52
查看更多