Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
501 views
in Technique[技术] by (71.8m points)

父组件子组件传递值问题

父组件:api是请求的url,改变refresh(子组件中监听这个值,变化了就重新请求)即可重新请求

<el-dialog>
    <page-table
        checkBox
        pagination
        :api="handleListApi"
        :refresh="handleInfo.refresh"
        :data.sync="handleInfo.data"
        :query="handleFilterInfo.query"
        :list-type-info="listTypeInfo"
        :init-curpage="handleInfo.initCurpage"
        :field-list="handleInfo.fieldList"
        :handle="handleInfo.handle"
        @handleEvent="handlePersonEvent"
        @handleClick="handleClick"
      />
</el-dialog>

js部分代码:

handleInfo:{
        refresh:1,
        initCurpage:1,
        data:[],
        fieldList:[
          {label:'姓名',value:'personName',minWidth:150,tooltip:true},
          {label:'人员编号',value:'personCode',minWidth:150,tooltip:true},
          {label:'身份证号',value:'idCardNumber',minWidth:150,tooltip:true},
        ]
      },
      handleFilterInfo:{
        query:{
          deviceIds:[],
          personName:'',
          personCode:'',
          idCardNumber:'',
        },
        list:[
          {type:'input',label:'姓名',value:'personName',hideLabel:true},
          {type:'input',label:'人员编号',value:'personCode',hideLabel:true},
          {type:'input',label:'身份证号',value:'idCardNumber',hideLabel:true},
          {type:'button',label:'查询',btType:'submit',icon:'',event:'searchPerson',show:true},
        ]
      },

然后在子组件中进行一系列的操作。
问题:我在页面中选中表格数据后,点击按钮(改变refresh值),将选中的值传到dialog中,第一次dialog中的表格没有数据,第二次点击按钮时,才有值,不知道咋搞了


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

解决方法:在点击按钮将visible设置为true后,在$nextTick()里面修改refresh的值


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...