Skip to content

Instantly share code, notes, and snippets.

@ryangjchandler
Last active June 22, 2021 15:06
Show Gist options
  • Save ryangjchandler/2c807d0124d5d0550610aed51d919dad to your computer and use it in GitHub Desktop.
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