【发布时间】:2021-07-15 01:42:34
【问题描述】:
如何从 Vue.js 中的方法向函数传递值?
我在方法中得到了一个值,但是我需要将这个值传递给其他函数,我该怎么做?
methods: {
getDataSource() {
let self = this;
arr.forEach((item) => {
//debugger;
let tokens = item.path.replace(/^\/|\/$/g, "").split("/");
let fid = item.fid;
let current = tree;
for (let i = 0; i < tokens.length; i++) {
if (!current[tokens[i]]) {
current[tokens[i]] = {
fid: item.fid
};
}
current = current[tokens[i]];
}
let ffid = Number(item.fid) + 1;
//console.log(ffid);
});
}
function uploadFileChunk(fileData, uploadInfo, destinationDirectory) {
let self = this;
//debugger
let reader = new FileReader();
reader.onload = function() {
console.log(reader.result);
}
reader['readAsDataURL'](fileData);
return objectProvider.uploadFileChunk(
fileData,
uploadInfo,
destinationDirectory
);
}
我想将 ffid 值传递给函数 uploadFileChunk,如何获得 ffid 值?
【问题讨论】:
-
这个uploadFileChunk 是在哪里定义的?它是否在方法部分下的同一文件中定义?
-
你试过什么?大概你会打电话给
uploadFileChunk(ffid, someUploadInfo, someDestinationDirectory)。那不行吗? -
@Amaarrockz 那是方法之外的功能。
-
@Phil yse,它不起作用,所以我不能使用它
-
@Amaarrockz 这是同一个文件,但不在方法部分中
标签: javascript function vue.js vuejs2