Safari: TypeError: A Proxy's 'target' should be an Object
Safari: TypeError: A Proxy's 'target' should be an Object
我正在使用网络音频,我有以下代码在 Chrome 中工作正常但在 Safari 中不工作。
const audioContextList = [];
(function () {
self.AudioContext = new Proxy(self.AudioContext, {
construct(target, args) {
const result = new target(...args);
audioContextList.push(result);
return result;
}
});
})();
在 Safari 中,我收到以下错误:
TypeError: A Proxy's 'target' should be an Object
我该如何解决这个问题?
Safari 13.1 supports AudioContext
供应商前缀:webkit。
因此您应该使用 self.webkitAudioContext
访问它。
或者你可以做一种跨浏览器的解决方案
let AudioContext = self.AudioContext || self.webkitAudioContext;
self.AudioContext = new Proxy(AudioContext, {
construct(target, args) {
const result = new target(...args);
audioContextList.push(result);
return result;
}
});
我正在使用网络音频,我有以下代码在 Chrome 中工作正常但在 Safari 中不工作。
const audioContextList = [];
(function () {
self.AudioContext = new Proxy(self.AudioContext, {
construct(target, args) {
const result = new target(...args);
audioContextList.push(result);
return result;
}
});
})();
在 Safari 中,我收到以下错误:
TypeError: A Proxy's 'target' should be an Object
我该如何解决这个问题?
Safari 13.1 supports AudioContext
供应商前缀:webkit。
因此您应该使用 self.webkitAudioContext
访问它。
或者你可以做一种跨浏览器的解决方案
let AudioContext = self.AudioContext || self.webkitAudioContext;
self.AudioContext = new Proxy(AudioContext, {
construct(target, args) {
const result = new target(...args);
audioContextList.push(result);
return result;
}
});