关于前端:VUE组件的封装父组件向子组件传值

1.调用

import info from './priceDetail.vue'
components: { Treeselect, info },
<info></info>

2.父组件向子组件传值

v-bind:name=””

eg:

父:

<info v-bind:type="type" v-bind:row="row"></info>
handleClick(row) {
       console.log(row)
       this.dialogTableVisible = true
       this.row=row//传递的row
     },

子:

props: {
      type: {
        type: String,
        required: true,
      },
      row:{
        type:Object,
        required:true
      }
    },
 <el-descriptions title="详细信息" v-if="type == 'bw'">
created() {
      console.log(this.type)
      console.log('row',this.row)
    },

3.note:

子组件承受的父组件的值分为——援用类型和一般类型两种,
一般类型:字符串(String)、数字(Number)、布尔值(Boolean)、空(Null)
援用类型:数组(Array)、对象(Object)

评论

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

这个站点使用 Akismet 来减少垃圾评论。了解你的评论数据如何被处理