<div id="app">
<child :my-name="name" :my-age="age"></child>
</div>
<template id="child">
<div class="child">
<h3>子组件child数据</h3>
<ul>
<li>
<label>姓名</label>
<span>{{ myName }}</span>
</li>
<li>
<label>年龄</label>
<span>{{ myAge }}</span>
</li>
</ul>
</div>
</template>
html,body {
margin: 0;
padding: 0;
}
body {
height: 100vh;
width: 100vw;
display: flex;
justify-content: center;
align-items: center;
background-color: #f44336;
}
.child {
min-width: 30vw;
background-color: #FFF;
position: relative;
overflow: hidden;
user-select: none;
box-shadow: 0px 5px 43px rgba(0, 0, 0, 0.18);
border-radius: 3px;
padding: 2vw;
}
h3 {
font-size: 24px;
font-weight: 400;
margin-top: 0;
margin-bottom: 0;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
box-sizing: border-box;
padding: 0 20px;
text-align: center;
color: #263238;
&:after {
content: "";
background-color: #E3EBEE;
width: 70px;
height: 1px;
margin: 20px auto 0 auto;
display: block;
}
}
ul {
margin: 20px 0 0;
padding: 0;
list-style: none outside none;
display: flex;
justify-content: center;
align-items: center;
li {
padding: 10px;
display: flex;
flex-direction: column;
text-align: center;
min-width: 10vw;
justify-content: center;
align-items: center;
&:not(:last-child) {
border-right: 1px solid #ccc;
}
}
}
span {
font-size: 18px;
color: #90a4ae;
white-space: nowrap;
display: block;
margin-top: 15px;
}
View Compiled
let parent = new Vue({
el: '#app',
data () {
return {
name: 'w3cplus',
age: 7
}
},
components: {
'child': {
template: '#child',
props: ['myName', 'myAge']
}
}
})
View Compiled
This Pen doesn't use any external CSS resources.