Feature: Use function instead of logic in mounted function

This commit is contained in:
winkidney
2019-03-01 13:37:02 +08:00
committed by Isaac Bythewood
parent c56320ac5d
commit c2050fa76f

View File

@@ -20,13 +20,16 @@ Vue.component('pin', {
props: ['pin', 'args', 'index'], props: ['pin', 'args', 'index'],
template: '#pin-template', template: '#pin-template',
mounted: function() { mounted: function() {
this.imageStyle = { this.imageStyle = this.getImageStyle();
width: this.pin.image.thumbnail.width + 'px',
height: this.pin.image.thumbnail.height + 'px',
};
this.pinStyle = this.getPinStyle(); this.pinStyle = this.getPinStyle();
}, },
methods: { methods: {
getImageStyle: function() {
return {
width: this.pin.image.thumbnail.width + 'px',
height: this.pin.image.thumbnail.height + 'px',
}
},
getPinStyle: function() { getPinStyle: function() {
var self = this; var self = this;
@@ -52,6 +55,7 @@ Vue.component('pin', {
function getLineNumber(rowSize, index) { function getLineNumber(rowSize, index) {
return Math.floor((index) / rowSize); return Math.floor((index) / rowSize);
} }
var lineNumber = getLineNumber(self.args.rowSize, self.index); var lineNumber = getLineNumber(self.args.rowSize, self.index);
marginTop = self.args.blockMargin + (self.args.blockMargin + 300) * lineNumber; marginTop = self.args.blockMargin + (self.args.blockMargin + 300) * lineNumber;