vue 部署项目的时候报错 Syntax Error: TypeError: token.type.endsWith is not a function 有没有小伙伴遇到过类似问题 请指教!!
vue 部署项目的时候报错 Syntax Error: TypeError: token.type.endsWith is not a function 有没有小伙伴遇到过类似问题 请指教!!
endsWith 方法不支持, 解决方案有两种
重写 string 类型的 endsWith 方法
if (!String.prototype.endsWith) {
//判断String这个对象原型是否有endsWith方法,没有的话,就用加上这个方法
Object.defineProperty(String.prototype, 'endsWith', {
enumerable: false,
configurable: false,
writable: false,
value: function (searchString, position) {
position = position || this.length;
position = position - searchString.length;
var lastIndex = this.lastIndexOf(searchString);
return lastIndex !== -1 && lastIndex === position;
}
});
}
帮忙支持我的工具
13 回答13.1k 阅读
8 回答3k 阅读
3 回答1.5k 阅读✓ 已解决
2 回答5.3k 阅读✓ 已解决
5 回答1.6k 阅读
9 回答1.8k 阅读✓ 已解决
6 回答1.8k 阅读
看一下是不是跟这个问题一样,也是我回答的:https://segmentfault.com/q/10...