0

我正在重构我的 javascript 代码,现在我遇到了一个问题,如果我在不使用函数的情况下将代码放入函数中,它就无法正常工作,见下文:

不工作:

function getFolderPath(){
    var winLocHref =  window.location.href;
    var path = winLocHref.substr(8+document.domain.length);
    var splits=path.split("/");
    path=path.substr(0,path.length-splits[splits.length-1].length);
    path = path.replace(/\//g, '\\\\');
    return path;
}
function getXlsxAbsolutePath(){
    var xslPath = getFolderPath() + "seating_plan_demo.xlsx";
    return xslPath;
}

var excel_file = excel.Workbooks.Open(getXlsxAbsolutePath());

在职的:

var   a   =  window.location.href;
var path = a.substr(8+document.domain.length);
var A=path.split("/");
path=path.substr(0,path.length-A[A.length-1].length);
path = path.replace(/\//g, '\\\\');
xslPath = path + "seating_plan_demo.xlsx";

var excel_file = excel.Workbooks.Open(xslPath);

谁能告诉我我的问题是什么?

干杯。

4

0 回答 0