Between the traditional values Vue assembly (parent-child)

           

Parent component code is as follows:

 1 <template>
 2     <div>
 3         <div>父组件</div>
 4         <child :message="parentMsg"></child>  
 5     </div>
 6 </template>
 7  
 8 <script>
 9  
10 import child from './child'  //引入child组件
11 export default {
12     data() {
13             return {
14                 parentMsg: 'a message from parent'  //Defined values need to pass in data 
15              }
 16          },
 . 17          Components: {
 18 is              Child
 . 19          }
 20 is  }
 21 is </ Script>
 22 is <style>
 23 is </ style>

Subassembly pass the value code as follows:

. 1 <Template>
 2      <div>
 . 3          <div> {{Message}} (sub-assembly) </ div>
 . 4      </ div>
 . 5 </ Template>
 . 6 <Script>
 . 7 Export default {
 . 8      The props: {
 . 9          Message: String   // type <br> pass defined value} 
10  }
 . 11 </ Script>
 12 is <style>
 13 is </ style>

 

Guess you like

Origin www.cnblogs.com/CinderellaStory/p/11527241.html