vue 一个js文件内export 多个function, 内部function互调使用

方法一、

index.js

import { getBytesLength as sss } from "@/utils/index";  // sss 为别名

export function reSetNameBreadcrumb(name, lengthArr){
  console.log(sss("xxx"))   // 调用内部方法
 }

export function getBytesLength (str) {
    return str
}

调用方式:

import { reSetNameBreadcrumb } from "@/utils/index"; 


reSetNameBreadcrumb("", "")

方法二、

test.js

function test1(str) {
  test2(str);
}

function test2(str) {
  console.warn(str);
}

export default {
  test1,
  test2
};

调用方式:

import ccc from "@/utils/test";

ccc.test1("xxxxxx");
Logo

前往低代码交流专区

更多推荐