【发布时间】:2020-07-06 12:07:45
【问题描述】:
我是使用 Vue 的新手。我从使用类风格的绑定语法开始。 我在 CSS 中定义的页眉和页脚类没有显示,尽管在组件标签中引用了它们。我似乎无法弄清楚为什么。
我尝试将类放入组件中,但它们似乎也没有显示在那里。我有一种感觉,我必须在 Vue App 初始化程序中以某种方式绑定类?
提前致谢!
App.vue
<template>
<div id="app">
<div class="container">
<section>
<LauchLogo class="header" />
<LauchSymbol class="footer" />
</section>
<section>
<LauchLogo class="header" />
<LauchSymbol class="footer" />
</section>
</div>
</div>
</template>
<script lang="ts">
import { Component, Vue } from "vue-property-decorator";
import LauchLogo from "./components/LauchLogo.vue";
import LauchSymbol from "./components/LauchSymbol.vue";
@Component({
components: {
LauchLogo,
LauchSymbol
}
})
export default class App extends Vue {
data() {
return {
logo: 'logo',
symbol: 'symbol'
}
}
}
</script>
<style>
#app {
font-family: Avenir, Helvetica, Arial, sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
text-align: center;
color: #2c3e50;
}
body {
height: 100vh;
overflow: hidden;
}
* {
margin: 0;
padding: 0;
}
.container {
width: 100%;
height: 100%;
overflow-y: scroll;
scroll-behavior: smooth;
scroll-snap-type: y mandatory;
}
section {
display: flex;
flex-direction: column;
align-items: center;
justify-content: space-evenly;
width: 100vw;
height: 100vh;
scroll-snap-align: center;
}
.footer {
border: 2px green;
}
.header {
border: 2px blue;
}
</style>
LauchSymbol.vue
<template>
<div class="container">
<img class="responsiveLauch alignMiddle bounce" src="../assets/JustLauch.png"/>
</div>
</template>
<script lang="ts">
import { Component, Prop, Vue } from "vue-property-decorator";
@Component
export default class HelloWorld extends Vue {
//this is where you put your code
// @Prop() private msg!: string;
ScrollNext () {
alert("hello");
}
}
</script>
<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
.responsiveLauch {
max-width: 5%;
height: auto;
}
.bounce {
animation: bounce 2s;
/* animation-delay: 1s; */
animation-iteration-count: infinite;
}
@keyframes bounce {
0%,
25%,
50%,
75%,
100% {
transform: translateY(0);
}
40% {
transform: translateY(-80px);
}
60% {
transform: translateY(-42px);
}
}
</style>
LauchLogo.vue
<template>
<div class="container">
<img class="responsiveLogo" src="../assets/LauchLogoTrimmed2.png"/>
</div>
</template>
<script lang="ts">
import { Component, Prop, Vue } from "vue-property-decorator";
@Component
export default class HelloWorld extends Vue {
//this is where you put your code
// @Prop() private msg!: string;
ScrollNext () {
alert("hello");
}
}
</script>
<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
.responsiveLogo {
max-width: 55%;
height: auto;
padding-bottom: 300px;
}
</style>
【问题讨论】:
-
你也能显示组件吗?
-
@AlexBrohshtut 我将其他组件添加为代码块。谢谢
标签: javascript html css vue.js