相关推荐recommended
解决:this.$refs引用子组件报错 is not a function
作者:mmseoamin日期:2023-12-02

解决:this.$refs引用子组件报错 is not a function

  • 问题描述:

    vue通过this.$refs引用子组件出现undefined或者is not a function的错误

  • 报错如下:

    _this3.$refs.fileUpload.changeFileList is not a function


    问题分析:

    • 问题1:出现undefined错误

      1. 包含子组件的标签需要放在中第一个子标签的子标签中,而且需要设置ref属性,

        因为父组件逻辑代码中是通过该属性调用子组件的方法或者属性的。

    • 问题2: 出现is not a function的错误

      1. 子组件需要import,import是请确保路径正确
      2. import之后还需要在父组件的component中进行注册

      解决办法:

      • 按上述分析对号入座进行修改即可。

        完结。