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;
}
});
}
帮忙支持我的工具
10 回答11.2k 阅读
5 回答4.8k 阅读✓ 已解决
4 回答3.1k 阅读✓ 已解决
2 回答2.7k 阅读✓ 已解决
3 回答5.1k 阅读✓ 已解决
3 回答1.9k 阅读✓ 已解决
2 回答4.7k 阅读✓ 已解决
看一下是不是跟这个问题一样,也是我回答的:https://segmentfault.com/q/10...