vue.js propsプロパティ


🌱 vueのpropsプロパティについて


🔸 重要🔸
  • 親(親)構成部品から子(子)構成部品に送信されます.
    (emitとは逆)
  • は、すべてのタイプの変数をサポートします.
  • props 속성 작성 방법)
    <!-- HTML에서의 kebab-case -->
    <template>
    	<child-component post-title="hello!"></child-component>
    </template>
    ...
    <script>
      Vue.component('child-component', {
          //----- JavaScript에서의 camelCase
        props: ['postTitle(props속성 이름)'],
        template: '<h3>{{ postTitle }}</h3>'
      })
    </script>
    props 속성 작성 예시)
    
    <template>
       <div id='test'> ----- id.test로 연결해준 👉 상위 컴포넌트 부분!!
          <child-component :peopleData='name'> 
         	   상위로부터 props 받은 하위 컴포넌트 부분
          </child-component>
       </div>
    </template>
    <script>
       Vue.component('child-component',{
       	 props: ['peopleData'],
         template: '<p>{{peopleData}}</p>'
       })
    </script>