2017-04-05 41 views
0

Shopify有一个非常有用的method在其Embedded App SDK用于显示一个红色的小浮态错误:ShopifyApp.flashError("Your error");我怎样才能在ShopifyApp.flashError具有多错误()

我的问题是,我不能在这多错误。我试过\n,/n,/r,\r,<br />&#013,因为它有newline。没有工作!有任何想法吗?

+0

你有没有偷看到'flashError'方法的源代码?答案可能在那里。 – Forty3

+0

感谢您的建议@ Forty3。但我相信我们无法访问Shopify源代码! – zahra

回答

1

貌似ShopifyApp.flashError使得以postMessage的一个电话:

e.postMessage = function(e, t) { 
    var r; 
    return null == t && (t = {}), r = JSON.stringify({ 
     message: e, 
     data: t 
    }), 
    n("client sent " + r + " to " + this.shopOrigin), 
    window.parent.postMessage(r, this.shopOrigin), 
    null != t ? t.callbackId : void 0 
}, e.flashNotice = function(e) { 
    return this.postMessage("Shopify.API.flash.notice", { 
    message: e 
    }) 
}, e.flashError = function(e) { 
    return this.postMessage("Shopify.API.flash.error", { 
    message: e 
    }) 
} 

所以,如果你能找到被监听发送到“Shopify.API.flash.error”消息逻辑位即可找到呈现消息的代码。然而,考虑到r = JSON.stringify({ message: e, data: t})的调用,我怀疑你是运气不足,因为传递足够特殊的字符来调用换行符。