通信:父组件 -> 子组件 

父组件
<!--这里需要用v-bind来绑定data中的fontsize,否则传过去的只是一个字符串"fontsize"-->
<BtnAdd v-bind:fontSize="fontsize"></BtnAdd>



子组件
<template>
  <div>
    <!--内联css,也要用到v-bind,{}内的格式有要求,详见官方文档"Class 与 Style 绑定"-->
    <p v-bind:style="{ fontSize: fontSize+'em' }">{{fontSize}}</p>
  </div>
</template>
<script>
export default {
  props: ["fontSize"]
};
</script>

 

相关文章:

  • 2021-11-22
  • 2022-01-09
  • 2022-12-23
  • 2021-06-05
  • 2021-05-22
猜你喜欢
  • 2021-12-25
  • 2021-11-11
  • 2021-11-27
  • 2022-01-15
  • 2022-02-13
  • 2021-08-27
相关资源
相似解决方案