propsData 不是和属性有关,他用在全局扩展时进行传递数据。
<header id="header"></header>
<script>
var header_a=Vue.extend({
template:`<p>{{message}}{{a}}</p>`,
data:function(){
return{
message:'hello'
}
},
props:['a']
});
new header_a({propsData:{a:1}}).$mount("#header")
</script>

 如果我们要传递一个值过去,这时就用到了propsData。

使用propData传值的步骤: 

1.在全局扩展实例中:propsData:{a:1}

2.传递的时候用props接收属性:props:["a"] 

3. 写入模板:{{a}}

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-09-19
  • 2022-12-23
  • 2022-12-23
  • 2021-04-02
  • 2021-07-12
  • 2022-01-31
相关资源
相似解决方案