skip to Main Content

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>

https://jsfiddle.net/y9wbz3dg/1/

2

Answers


  1. Chosen as BEST ANSWER

    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.

    <script defer src="https://unpkg.com/[email protected]/dist/cdn.min.js"></script>
    

  2. I found that i was including AlpineJs twice, once at <head> and another before </body>

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search