Heim  >  Fragen und Antworten  >  Hauptteil

javascript - Wie rufe ich native App-Methoden (Android, iOS) in VueJS auf?

Ich habe eine Methode definiert, um die Methode der App aufzurufen

$.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);

Aber wie nutzt man die nativen Methoden auf der App-Seite in Vue?

漂亮男人漂亮男人2713 Tage vor923

Antworte allen(1)Ich werde antworten

  • 世界只因有你

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

    同样的写法。vue里难道就没有window对象了?

    Antwort
    0
  • StornierenAntwort