A Pen by Oliver Schafeld on CodePen.
Created
November 13, 2024 13:57
-
-
Save schafeld/bc68fce60eb1e8791e1ad41507ec3fe4 to your computer and use it in GitHub Desktop.
Vue without Build Step
This file contains hidden or 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
| <!-- | |
| Code lifted from: | |
| https://github.com/MicrosoftDocs/mslearn-vue-dynamic-render/blob/main/end/index.html | |
| Course: | |
| https://learn.microsoft.com/en-us/training/modules/vue-dynamic-rendering/3-render-lists-exercise | |
| --> | |
| <div class="nav-bar"></div> | |
| <h1>Relecloud Galaxy Tours</h1> | |
| <div id="app"> | |
| <h2>{{ productName }}</h2> | |
| <div>{{ productDescription }}</div> | |
| <hr /> | |
| <!-- TODO: Add code to display classes --> | |
| <div v-for="(productClass, index) in productClasses" :key="index" class="row"> | |
| <div> | |
| {{ productClass.name }} | |
| </div> | |
| <div> | |
| $ {{ productClass.price.toLocaleString('en-US') }} | |
| </div> | |
| <!-- More to come --> | |
| <button v-if="productClass.earlyBird" class="button">Book early bird!</button> | |
| <button v-else class="button">Book now!</button> | |
| <div v-show="productClass.seatsAvailable < 10">Almost sold out!</div> | |
| </div> | |
| <img v-bind:src="productImage" v-bind:alt="productImageDescription" :style="productImageStyle" /> | |
| </div> |
This file contains hidden or 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
| const app = Vue.createApp({ | |
| data() { | |
| return { | |
| productName: 'Book a Cruise to the Moon', | |
| productDescription: 'Cruise to the moon in our luxurious shuttle. Watch the astronauts working outside the International Space Station.', | |
| productImage: 'assets/cruise.jpg', | |
| productImageDescription: 'An astronaut floats outside the window while you sit in comfort', | |
| productImageStyle: { | |
| 'border-radius': '15px' | |
| }, | |
| productClasses: [ | |
| { | |
| name: 'Coach', | |
| price: 125000, | |
| seatsAvailable: 20, | |
| earlyBird: true | |
| }, | |
| { | |
| name: 'Business', | |
| price: 275000, | |
| seatsAvailable: 6, | |
| earlyBird: true | |
| }, | |
| { | |
| name: 'First', | |
| price: 430000, | |
| seatsAvailable: 2, | |
| earlyBird: false | |
| } | |
| ] | |
| } | |
| }, | |
| }); | |
| app.mount('#app'); |
This file contains hidden or 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
| <script src="https://cdnjs.cloudflare.com/ajax/libs/vue/3.2.37/vue.global.prod.min.js"></script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment