july89 2022-03-28 16:11 采纳率: 80%
浏览 240
已结题

vue中接收一个export导出的JS方法模块,但是有两个方法始终调用失败

img

img

img

_temp_check和 _temp_check_getresult 方法始终在页面里报错,
没有用箭头函数用普通的 function+方法名也不对 不知道是哪里写错了

  • 写回答

9条回答 默认 最新

  • rock.dai 2022-03-28 17:21
    关注

    你的定义有问题,等于是没有给_temp_check和_temp_check_getresult进行声明就调用赋值函数
    修改一下:

    export const realMcom=()=>{
        const _team_check=(callback)=>{
    
        }
        const _team_check_getresult=()=>{
    
        }
    }
    

    还有,了 年 2202 都,咱能不用var就别用好不?

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论 编辑记录
  • 众生皆苦唯有我甜 2022-03-28 16:18
    关注

    js文件导出的是一个函数,引入文件引用的是对象属性 怎么会对呢

    评论
  • 崽崽的谷雨 2022-03-28 16:21
    关注

    你这样写就是 realMcom 包含了 _temp_check和 _temp_check_getresult

    使用时 应该是 realMcom._temp_check()

    报 _temp_check() 未定义 ?那 哪里用到它了

    评论 编辑记录
  • 歇歇 2022-03-28 16:33
    关注

    挂载钩子中的错误:“引用错误:_temp_ucheck未定义”
    var _temp_ucheck import $ from 'jquery';
    var _temp_check_getresult import $ from 'jquery';

    评论
  • yhanw 2022-03-28 16:38
    关注

    var _temp_check = () => {};
    var _temp_check_getresult = {};

    就不报错了嘛。

    或者你是想直接导出一个对象
    export const realMcom = {
    _temp_check: () => {}
    _temp_check_getresult: () => {}
    }

    更或者你是想执行realMcom()函数后返回一个对象
    export const realMcom = () => ({
    _temp_check: () => {}
    _temp_check_getresult: () => {}
    })

    评论
  • greatofdream 2022-03-28 19:46
    关注

    js模块写的有问题,需要对变量声明

    评论
  • 太空眼睛 Java领域新星创作者 2022-03-29 07:16
    关注

    因为变量没有声明,把需要调用的函数正确返回即可

    评论
  • 在下月亮有何贵干 前端领域优质创作者 2022-03-29 09:01
    关注

    暴露方法两种
    你这里用的是属性暴露。
    你使用_temp_check和_temp_check_getresult,它们也要暴露。

    export const realMcom = () => {
       ...
    }
    export const _temp_check = (callback) => {
       ...
    }
    export const _temp_check_getresult = () => {
      ...
    }
    
    import { realMcom, _temp_check, _temp_check_getresult } from "@/utils/index"
    ...
    
    评论
  • 音药 2022-03-28 17:39
    关注
    
    const _temp_check = (callback) => {
        console.log(111222)
        callback()
    }
    const _temp_check_getresult = () => {
        console.log(111222333)
    }
    export {_temp_check, _temp_check_getresult}
    
    
    
    import {_temp_check, _temp_check_getresult} from "@/utils/index"
    console.log(_temp_check)
          _temp_check()
          _temp_check_getresult()
    
    

    https://www.cnblogs.com/Listener-wy/p/14933478.html 看看这个

    评论 编辑记录
查看更多回答(8条)

报告相同问题?

问题事件

  • 系统已结题 4月9日
  • 已采纳回答 4月1日
  • 创建了问题 3月28日

悬赏问题

  • ¥15 k210显示failed init to model
  • ¥15 Evil-droid生成的APK手机已经下载但无法建立任务
  • ¥25 c语言韩信点兵的变式
  • ¥15 怎么根据书上的例子完成这个问题呢?
  • ¥15 ECharts 增加Zoom,整行包括右边的Text一起滑动
  • ¥15 关于网上一个easyx制作的见缝插针小游戏(c++)
  • ¥15 开地址法双散列函数处理碰撞
  • ¥15 想问一下这个是什么情况 虚拟机Linux打不开了
  • ¥15 联通光猫掉注册了怎么重新注册上去
  • ¥15 关于unity开发steamvr程序遇到的问题