javascript - 编辑已经缩小的 JavaScript 片段
问题描述
我必须将下面的缩小片段编辑为:如果消息(字符串)由包含单词API的片段处理,则将整个消息更改为出错了。稍后再试。请让我知道我该怎么做。谢谢!
wc_myplugin.BaseGateway.prototype.submit_error = function(t) {
var e = this.get_error_message(t);
e.indexOf("</ul>") < 0 && (e = '<div class="' + function() {
var t = "woocommerce-MyPlugin";
return this.is_current_page("checkout") && (t += " woocommerce-MyPlugin-checkout"), t
}.bind(this)() + '"><ul class="woocommerce-error"><li>' + e + "</li></ul></div>");
t = o(document.body).triggerHandler("wc_myplugin_submit_error", [e, t, this]);
e = void 0 === t ? e : t, this.submit_message(e)
解决方案
我var eMessage = e.contains('API') ? 'Something went wrong. Try again later' : e;
在第三行添加。基本上,检查错误消息是否包含“API”(大写字母)。如果是,则替换错误消息,否则保持不变。
wc_myplugin.BaseGateway.prototype.submit_error = function(t) {
var e = this.get_error_message(t);
var eMessage = e.contains('API') ? 'Something went wrong. Try again later' : e;
e.indexOf("</ul>") < 0 && (e = '<div class="' + function() {
var t = "woocommerce-MyPlugin";
return this.is_current_page("checkout") && (t += " woocommerce-MyPlugin-checkout"), t
}.bind(this)() + '"><ul class="woocommerce-error"><li>' + eMessage + "</li></ul></div>");
t = o(document.body).triggerHandler("wc_myplugin_submit_error", [e, t, this]);
e = void 0 === t ? e : t, this.submit_message(e)
推荐阅读
- c# - Xamarin Foms UWP - KnownFolders.PicturesLibrary 现在返回 OneDrive
- flutter - 颤振容器匹配列内的父级
- swift - 向下转型多态性和赋值
- vue.js - (VueJS)每当显示时更新组件
- django - Django excludefiled__in 不过滤数据
- elasticsearch - 为什么我得到的桶数总是等于聚合方面的指定大小?
- java - 如何让多个 Java 线程根据用户的请求暂停和恢复?
- nlog - 未为记录器配置目标。Linux + 单声道
- sql - 如何强制在 SQL 中缺少连接?
- r - R Shiny“错误:要写入的文本必须是长度为一的字符向量”