_temp_check和 _temp_check_getresult 方法始终在页面里报错,
没有用箭头函数用普通的 function+方法名也不对 不知道是哪里写错了
你的定义有问题,等于是没有给_temp_check和_temp_check_getresult进行声明就调用赋值函数
修改一下:
export const realMcom=()=>{
const _team_check=(callback)=>{
}
const _team_check_getresult=()=>{
}
}
还有,了 年 2202 都,咱能不用var就别用好不?
js文件导出的是一个函数,引入文件引用的是对象属性 怎么会对呢
你这样写就是 realMcom 包含了 _temp_check和 _temp_check_getresult
使用时 应该是 realMcom._temp_check()
报 _temp_check() 未定义 ?那 哪里用到它了
挂载钩子中的错误:“引用错误:_temp_ucheck未定义”
var _temp_ucheck import $ from 'jquery';
var _temp_check_getresult import $ from 'jquery';
var _temp_check = () => {};
var _temp_check_getresult = {};
就不报错了嘛。
或者你是想直接导出一个对象
export const realMcom = {
_temp_check: () => {}
_temp_check_getresult: () => {}
}
更或者你是想执行realMcom()函数后返回一个对象
export const realMcom = () => ({
_temp_check: () => {}
_temp_check_getresult: () => {}
})
js模块写的有问题,需要对变量声明
因为变量没有声明,把需要调用的函数正确返回即可
暴露方法两种
你这里用的是属性暴露。
你使用_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"
...
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()