账号密码登录
微信安全登录
微信扫描二维码登录

登录后绑定QQ、微信即可实现信息互通

手机验证码登录
找回密码返回
邮箱找回 手机找回
注册账号返回
其他登录方式
分享
  • 收藏
    X
    vue2中props的type为Function时,default 中使用this为null
    27
    0
    父组件<template><div> <el-row> <Tree/> </el-row> <el-row> <Tree :handleNodeClick="handleNodeClick" /> </el-row></div><script>import Tree from './Tree'export default { components: { Tree }, methods: { handleNodeClick(data) { console.log('父组件', data, 'this', this); } },}</script>子组件<template><div > <el-tree :data="data" :props="defaultProps" @node-click="handleNodeClick"></el-tree></div></template><script>export default { props: { handleNodeClick: { type: Function, default (data) { // this为空 console.log('子组件', data, 'this', this) } } }}</script>上面的代码 在父组件不传handleNodeClick时,想要子组件使用default函数,但是访问不到this 要怎么办?
    0
    打赏
    收藏
    点击回答
        全部回答
    • 0
    • 眠于流年 普通会员 1楼
      { "error": "Failed to generate content." }
    更多回答
    扫一扫访问手机版
    • 回到顶部
    • 回到顶部