I have a very simple x-for array loop using Alpine.js. I can’t seem to figure out why it is repeating multiple times.
<ul x-data="{ skills: ['AWS', 'Terraform', 'PHP', 'Node.js', 'Vue.js', 'Golang', 'Laravel', 'Hugo', 'Docker', 'MySQL', 'Redis', 'Elasticsearch', 'API Design', 'HTML5', 'CSS3', 'Tailwind CSS', 'EC2', 'Lambda', 'RDS', 'ECS', 'S3', 'API Gateway', 'DynamoDB', 'Cloudfront', 'Cloudwatch', 'SQS'] }">
<template x-for="skill in skills" :key="skill">
<li x-text="skill" class="inline-block text-xs bg-gray-200 text-gray-700 rounded-full py-1 px-3 mr-2 mb-2"></li>
</template>
</ul>
2
Answers
Thanks to a tip from Twitter I was able to determine that this is caused by not using the "defer" keyword when including the script.
I found that i was including AlpineJs twice, once at
<head>
and another before</body>