向Vue实例混入plusready

(function () {
    var onPlusReady = function (callback, context = this) {
        if (window.plus) {
            callback.call(context);
        } else {
            document.addEventListener('plusready', callback.bind(context));
        }
    };
    Vue.mixin({
        beforeCreate: function () {
            onPlusReady(function () {
                this.plusReady = true;
            }, this);
        },
        methods: {
            onPlusReady: onPlusReady
        }
    });
}());
posted @ 2018-08-21 12:16  月半流云  阅读(894)  评论(0编辑  收藏  举报