vue组件父组件传参数值给子组件

子组件

<template>
<div>
<h1>{{two}}</h1>
</div>
</template>

<script>
export default {
name: "Subcomp",
props:['one','two'],
data(){
return{
msg:'12121'
}
}
}
</script>

<style scoped>

</style>

父组件
<template>

<subcomp one="1111" two="222"></subcomp>

<div id="nav">
<router-link to="/">Home</router-link> |
<router-link to="/about">About</router-link>
|
<router-link to="/goods">goods</router-link>
</div>
<router-view/>
</template>
<script>
import Subcomp from "./components/Subcomp";
export default {
name: 'Home',
data(){
return {
num:0
}
},
components:{
Subcomp
}
}
</script>
<style>
#app {
font-family: Avenir, Helvetica, Arial, sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
text-align: center;
color: #2c3e50;
}

#nav {
padding: 30px;
}

#nav a {
font-weight: bold;
color: #2c3e50;
}

#nav a.router-link-exact-active {
color: #42b983;
}
</style>

文章来自 www.96net.com.cn
上一篇:linux系统oracle jdk快速安装


下一篇:JavaScript ES6 模块化