Skip to content

Instantly share code, notes, and snippets.

@ryangjchandler
Last active June 22, 2021 15:06
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save ryangjchandler/2c807d0124d5d0550610aed51d919dad to your computer and use it in GitHub Desktop.
<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