我正在创建一个Web应用程序,我想在其中转换字节int kb,mb.gb,tb。 (根据<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.1.2</version>
<configuration>
**<outputDirectory>${project.basedir}/target/test-classes</outputDirectory>**
</configuration>
<executions>
<execution>
<goals>
<goal>test-jar</goal>
</goals>
</execution>
</executions>
</plugin>
)
这是我的代码的样子
dropdownlistt
function changebyteintoselectedValue(bytes, si){
var thresh = si ? 1000 : 1024;
if(Math.abs(bytes) < thresh) {
return bytes + ' B';
}
var units = si
? ['kB','MB','GB','TB','PB','EB','ZB','YB']
: ['KB','MB','GB','TB','PB','EB','ZB','YB'];
var u = -1;
do {
bytes /= thresh;
++u;
} while(Math.abs(bytes) >= thresh && u < units.length - 1);
alert(bytes.toFixed(1)+' '+units[u]);
}
我想根据用户需要进行转换,但是现在它直接转换为mb,
如何根据用户选择转换字节?