/** * Setup instance methods. Methods must be bound to the * instance since they might be passed down as a prop to * child components. */ Vue.prototype._initMethods = function() { var methods = this.$options.methods if (methods) { for (var key in methods) { this[key] = bind(methods[key], this) } } }
function bind(fn, ctx) { return function(a) { var l = arguments.length return l ? l > 1 ? fn.apply(ctx, arguments) : fn.call(ctx, a) : fn.call(ctx) } }