【问题标题】:How do I include an image in a dialog with cordova-plugin-dialogs?如何在带有 cordova-plugin-dialogs 的对话框中包含图像?
【发布时间】:2018-03-21 20:20:48
【问题描述】:

我正在为 PhoneGap 使用cordova-plugin-dialogs 插件,根据我发现的讨论,可以在对话框中包含图像,但我无法找到方法。我在消息负载中尝试了 HTML 代码,但它不起作用。有人知道吗?

代码:

navigator.notification.confirm(
    '<img src="path/to/file.jpg">', // message
     onConfirm,                     // callback to invoke with index of button pressed
    'Upgrade',                      // title
    ['Upgrade Now','Cancel']        // buttonLabels
);

【问题讨论】:

    标签: cordova phonegap


    【解决方案1】:

    我认为不可能将任何图像\html 内容添加到此插件生成的对话框中,它只处理本机对话框的文本属性。 要存档,您需要编辑插件源代码并将任何图像添加到 android/ios 原生对话框类,然后通过 javascript 参数传递图像路径(或对其路径进行 harcode)。

    查看插件中 android 的原生实现示例:Source

    您需要在插件的第 170 行添加类似这样的内容以在本机对话框中设置任何图像:How to set image view in android dialog box?

    IOS 和 WP 也是如此。

    希望我对您有所帮助。

    编辑: 在 GIT 存储库的插件拉取请求中,我找到了添加 HTML 支持的拉取,然后您也可以尝试合并这个拉取插件源并将 HTML 图像发送到对话框内容(仅限alert 类型对话框):add support for html message in alert

    【讨论】:

      猜你喜欢
      • 2019-01-18
      • 2016-01-06
      • 1970-01-01
      • 1970-01-01
      • 2018-04-02
      • 1970-01-01
      • 1970-01-01
      • 2022-08-18
      • 2015-05-14
      相关资源
      最近更新 更多