夫传子
父组件代码
子组件代码
效果展示
<template> <h1>{{ msg }}</h1> </template> <script> export default { name: 'HelloWorld', props: { msg:{ type:String, default:"" } } } </script> <style > </style>子组件代码
<template> <div id="app"> <img alt="Vue logo" src="./assets/logo.png"> <MyComponent :msg="msg2"/> </div> </template> <script> import MyComponent from './components/MyComponent.vue' export default { name: 'App', data(){ return{ msg2:"Welcome222" } }, components: { MyComponent } } </script> <style> #app { font-family: Avenir, Helvetica, Arial, sans-serif; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; text-align: center; color: #2c3e50; margin-top: 60px; } </style>父组件代码
子传父
标签:间值,vue,default,代码,MyComponent,组件,font From: https://www.cnblogs.com/shuzhixia/p/16997938.html