Maison  >  Questions et réponses  >  le corps du texte

javascript - Comment appeler des méthodes d'applications natives (Android, iOS) dans VueJS?

J'ai défini une méthode pour appeler la méthode de l'application

$.execNativeCommand = function (command, data, options) {
    options = options || {};
    $.extend(true, options, defaultCommandOptions);
    return new Promise(function (r, j) {
        try {
            window.NativeBridge(command, data);        //NativeBridge是app 端注入的一个方法
            r();
        } catch (err) {
            if (options.showError) {
                $.alert("调用原生APP接口失败,错误消息:" + (err.message || "未知错误"));
            }
            if (options.gotoDownload) {
                var url = (options.getDownloadUrl || $.noop)(command, data);
                if (url) {
                    location.href = url;
                }
            }
            j();
        }
    });
}
调用方法:
 $.execNativeCommand('jumpGroupChat', cacheDetail.activityGroupId);

Mais comment utiliser les méthodes natives côté application dans Vue ?

漂亮男人漂亮男人2713 Il y a quelques jours919

répondre à tous(1)je répondrai

  • 世界只因有你

    世界只因有你2017-05-16 13:25:44

    Même méthode d'écriture. N'y a-t-il aucun objet window dans la vue ?

    répondre
    0
  • Annulerrépondre