【发布时间】:2022-01-08 04:37:22
【问题描述】:
我生成了一个 Vue.JS 项目,但遇到了问题。 实际上,我希望 App.vue 显示在整个页面上,并且我的不同路线使用路由器视图显示在 App.vue 中。
但是,当我尝试在我的 Game 组件的内容上设置边距时,似乎不是我的 Game 组件上而是 App 组件上的边距.
下面是我的两个 ".vue" 文件。
App.vue
<template>
<div id="app" class="bg-gray-500 h-full">
<router-view></router-view>
</div>
</template>
<script>
export default {
name:'App'
}
</script>
<style>
</style>
Game.vue
<template>
<div>
<div id="game">
<div class="bg-white rounded-lg p-6 w-1/2" style="margin-top:10px">
<h1>Hi</h1>
</div>
</div>
</div>
</template>
<script>
export default {
name: 'Game'
}
</script>
<style>
#game{
margin : -0px !important;
height: 100vh;
top:0;
background-color:red
}
</style>
问题是顶部的小白条,它不应该在那里,而是应该有 10px 顶部边距的白卡
编辑(main.js 文件):
import Vue from 'vue'
import App from './App.vue'
import '@/assets/css/tailwind.css'
import VueCookies from 'vue-cookies'
import VueRouter from 'vue-router'
Vue.config.productionTip = false
Vue.use(VueCookies)
Vue.use(VueRouter)
const router = new VueRouter({
mode:'history',
routes: [
{path: '/home', component: require('./components/Home.vue').default},
{path: '/', component:require('./components/Game.vue').default}
]
})
new Vue({
router,
render: h => h(App)
}).$mount('#app');
【问题讨论】:
标签: javascript html css vue.js vuejs2