javascript - How to call native app methods (Android, ios) in vuejs?
漂亮男人
漂亮男人 2017-05-16 13:23:44
0
1
996

I defined a method to call the app method

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

But how to use the native methods on the app side in vue?

漂亮男人
漂亮男人

reply all(1)
世界只因有你

Same way of writing. Is there no window object in vue?

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template