<template>
<div class="christmas-tree">
<div class="tree-top"></div>
<div class="tree-body">
<div v-for="(row, index) in treeRows" :key="index" class="tree-row">
<div v-for="(item, itemIndex) in row" :key="itemIndex" class="tree-item">{{ item }}</div>
</div>
</div>
</div>
</template>
<script>
export default {
data() {
return {
treeRows: [
[' ', ' ', ' ', '🎄', ' ', ' ', ' '],
[' ', ' ', ' ', '🎄', ' ', ' ', ' '],
[' ', ' ', '🎄', '🎄', '🎄', ' ', ' '],
[' ', '🎄', '🎄', '🎄', '🎄', '🎄', ' '],
['🎄', '🎄', '🎄', '🎄', '🎄', '🎄', '🎄'],
],
};
},
};
</script>
<style scoped>
.christmas-tree {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
height: 500px;
font-size: 30px;
}
.tree-body {
display: flex;
flex-direction: column;
align-items: center;
}
.tree-row {
display: flex;
justify-content: center;
}
.tree-item {
margin: 5px;
}
</style>
<template>
<div id="app">
<ChristmasTree />
</div>
</template>
<script>
import ChristmasTree from './components/ChristmasTree.vue';
export default {
components: {
ChristmasTree,
},
};
</script>
<style>
#app {
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
}
</style>
import { createApp } from 'vue';
import App from './App.vue';
import ChristmasTree from './components/ChristmasTree.vue';
createApp({
render() {
return (
<>
<ChristmasTree />
<App />
</>
);
},
}).mount('#app');
npm run serve
?运行成功截图如下
网页端效果如图:?
?
今天也是非常成功的一天!~又离高级工程师进了一步呢~