Heim  >  Fragen und Antworten  >  Hauptteil

Wie wird Anwendungs-CSS durch BootstrapVue-Tabellen überschrieben?

Ich habe eine einfache BootstrapVue-Tabelle.

CSS im App.vue 中定义。这是 App.vue ​​Code.

<template>
  <div id="app">
    <!-- <img alt="Vue logo" src="./assets/logo.png"> -->
    <TestTable msg="testing"/>
  </div>
</template>

<script>
import TestTable from './components/TestTable.vue'

export default {
  name: 'App',
  components: {
    TestTable
  }
}
</script>

<style>
#app {
  font-family: Avenir, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-align: center;
  color: #2c3e50;
  margin-top: 60px;  
}
</style>

Dies ist der Code für TestTable.vue.

<template>
  <div>
    <b-table striped hover :items="items"></b-table>
  </div>
</template>

<script>
  export default {
    data() {
      return {
        items: [
          { age: 40, first_name: 'Dickerson', last_name: 'Macdonald' },
          { age: 21, first_name: 'Larsen', last_name: 'Shaw' },
          { age: 89, first_name: 'Geneva', last_name: 'Wilson' },
          { age: 38, first_name: 'Jami', last_name: 'Carney' }
        ]
      }
    }
  }
</script>

margin-top: 60pxApp.vue 中定义。我想修改 TableTest.vue ,使其覆盖 App.vue 中 CSS 的边距顶部。我想要 margin-top: 0px 用于 TableTest.vue.

Ich verwende Vue v2.6 und Bootstrap-vue.

P粉545682500P粉545682500240 Tage vor320

Antworte allen(2)Ich werde antworten

  • P粉068510991

    P粉0685109912024-02-22 13:04:47

    你可以尝试margin-top:-60px;

    Antwort
    0
  • P粉821231319

    P粉8212313192024-02-22 11:49:21

    我之前评论过您的问题,您在父组件中应用了 margin-top: 60px ,而子组件有自己的盒子模型。

    添加代码片段以显示组件的结构:

    Vue.component('item', {
      template:'#list-template',
      props:['item'],
    });
    
    var vm = new Vue({
      el:"#app",
      computed: {
        limitedItems() {
          return ['item1'];
        }
      }
    });
    #app {
      border: 2px solid black;
      margin-top: 60px;
    }
    
    

    Antwort
    0
  • StornierenAntwort