【发布时间】:2022-12-13 14:04:45
【问题描述】:
我有这段代码:
if (!String.prototype.startsWith) {
Object.defineProperty(String.prototype, 'startsWith', {
enumerable: false,
configurable: false,
writable: false,
value: function(searchString, position) {
position = position || 0;
return this.lastIndexOf(searchString, position) === position;
}
});
}
我如何使用A.startsWith()将startsWith从A.js导出到B.js?
我尝试使用 exports Object.defineProperty(String.prototype, 'startsWith', { 但出现错误
在文件 B.js 中,我使用的是 import * as A from './A.js',但我无法使用 A.startsWith()。
我该如何解决?
谢谢你。
【问题讨论】:
标签: javascript