Last active
June 22, 2021 15:06
-
-
Save ryangjchandler/2c807d0124d5d0550610aed51d919dad to your computer and use it in GitHub Desktop.
This file contains 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
<div x-data="example()"> | |
<template x-for="(item, i) in items" :key="i"> | |
<div x-bind="props(i)"></div> | |
</template> | |
</div> | |
<script> | |
const example = () => ({ | |
current: 0, | |
items: [1, 2, 3], | |
props: (i) => ({ | |
// Can I access the loops item and i values in these functions? | |
['x-show']() { return this.current == i }, | |
['x-text']() { return item }, | |
}) | |
}); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment