Syntax Error: TypeError: Cannot read properties of null (reading ‘content‘)

文章讲述了在使用Vue的TypeScript版本开发时,MenuItem组件遇到错误,涉及context中null的content属性读取问题,寻求帮助解决语法错误。
摘要由CSDN通过智能技术生成

vue源代码
 

<script lang="ts">

export default {

  name: 'MenuItem',

  functional: true,

  props: {

    icon: {

      type: String,

      default: ''

    },

    title: {

      type: String,

      default: ''

    }

  },

  render(h, context) {

    const { icon = '', title = '' } = context ? context.props : {}

    const vnodes = []

    if (icon) {

      vnodes.push(<svg-icon icon-class={icon} />)

    }

    if (title) {

      vnodes.push(<span slot='title'>{(title)}</span>)

    }

    return vnodes

  }

}

</script>


报错
 

 ERROR  Failed to compile with 1 error                                                                                                                   23:41:39
 error  in ./src/layout/components/Sidebar/Item.vue?vue&type=script&lang=ts

Syntax Error: TypeError: Cannot read properties of null (reading 'content')
大佬能看看什么情况吗

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值