Last active
May 6, 2018 17:57
-
-
Save temistoclesarea/d649c406247daeb12199c393b3b6661b to your computer and use it in GitHub Desktop.
getPositionRand
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<template v-for="g in data.Zones"> | |
{{getPositionRand()}} // dessa forma ele chama o getPositionRand() | |
<a | |
class="zone" | |
???getPositionRand()??? // mas não sei chamar o method aqui | |
:title="'C:'+g.code+' T:'+g.time+' P:'+pos['p']+' H:'+pos['ph']+' W:'+pos['pw']" | |
:key="g.id" | |
:style="'width:'+pos['p']+'px;'+'height:'+pos['p']+'px;'+'top:'+pos['ph']+'px;'+'left:'+pos['pw']+'px;'" | |
:href="'#c:'+g.code"></a> | |
</template> | |
methods: { | |
getPositionRand: function (w = 800, h = 600) { | |
let pos = [] | |
pos['p'] = Math.floor(Math.random() * 18) + 4 | |
pos['pw'] = Math.floor(Math.random() * (w - pos['p'])) | |
pos['ph'] = Math.floor(Math.random() * (h - pos['p'])) | |
this.pos = pos | |
} | |
} | |
// solução | |
<a | |
class="zone" | |
v-for="g in data.Zones" | |
v-bind="getPositionRand()" | |
:title="'C:'+g.code+' T:'+g.time+' P:'+pos['p']+' H:'+pos['ph']+' W:'+pos['pw']" | |
:key="g.id" | |
:style="'width:'+pos['p']+'px;'+'height:'+pos['p']+'px;'+'top:'+pos['ph']+'px;'+'left:'+pos['pw']+'px;'" | |
:href="'#c:'+g.code"></a> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment