export var behavior = Behavior({ created: function created() { var _this = this; if (!this.$options) { return; } var cache = {}; var _this$$options = this.$options(), computed = _this$$options.computed; var keys = Object.keys(computed); this.calcComputed = function () { var needUpdate = {}; keys.forEach(function (key) { var value = computed[key].call(_this); if (cache[key] !== value) { cache[key] = needUpdate[key] = value; } }); return needUpdate; }; }, attached: function attached() { this.set(); }, methods: { // set data and set computed data set: function set(data, callback) { if (data) { this.setData(data, callback); } if (this.calcComputed) { this.setData(this.calcComputed()); } } } });