美文网首页Vue
vue专题:Props和动态 Props

vue专题:Props和动态 Props

作者: 俊瑶先森 | 来源:发表于2016-09-07 20:19 被阅读235次

Props

//child
export default {
  props: {
    msg: String
  }
}
<child msg="hello!"></child>

动态 Props

类似于用 v-bind
绑定 HTML 特性到一个表达式,也可以用 v-bind
绑定动态 Props 到父组件的数据。每当父组件的数据变化时,也会传导给子组件:

<div> 
<input v-model="parentMsg"> 
<br> 
<child v-bind:my-Props="parentMsg"></child>
</div>

使用 v-bind
的缩写语法通常更简单:

<child :my-Props="parentMsg"></child>

相关文章

网友评论

    本文标题:vue专题:Props和动态 Props

    本文链接:https://www.haomeiwen.com/subject/wmzjettx.html