属性 'split' 在类型 'string | ArrayBuffer' 上不存在。 属性 'split' 在类型 'ArrayBuffer' 上不存在 'ArrayBuffer'.ts(2339)

Property 'split' does not exist on type 'string | ArrayBuffer'. Property 'split' does not exist on type 'ArrayBuffer'.ts(2339)

"I want to split a base64Audio.Want to remove this - text.data:audio/wav;base64,So what will be the proper code "

“这是给 Angular 7 的。”

 const reader = new FileReader();
    reader.readAsDataURL(data.blob);
    let base64Audio ;
    reader.onloadend = function() {
      const base64data = reader.result;
      console.log(base64data);

     base64Audio = base64data.split(' , ')[1];
      console.log(base64Audio);

" 我希望输出应该只是拆分文本 "

const reader = new FileReader();
reader.readAsDataURL(data.blob);
let base64Audio ;
reader.onloadend = function() {
const base64data = reader.result as string;
console.log(base64data);
base64Audio = base64data.replace("data:audio/wav;base64,", "");
console.log(base64Audio);

尝试在使用 .split() 之前使用 .slice():

this.urlPath = this.urlpath.slice(0, 34);

这将帮助您获得所需的数组并删除不需要的数组,然后尝试从切片部分获得所需的数组,然后从那里尝试获得拆分的数组。

this.urlname = this.response.responseList[0].FileName;
this.urlname = this.urlname.split(".", 1);

这是我在拆分前使用 slice 的打字稿示例,因为我也遇到了同样的错误... 完整示例 link https://stackblitz.com/edit/angular-jyjs3v