Advertisement
supermaca

Untitled

Mar 30th, 2023
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.22 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <title>Title</title>
  5. <script src="https://unpkg.com/vue@next"></script> <!-- get latest version (seria 3) -->
  6. </head>
  7. <body>
  8.  
  9. <div id="app">
  10. <h1 v-if="showtitulo">{{ title }}</h1> <!-- DIRECTIVA 1 v-if solo se muestra titulo si showtitulo true -->
  11.  
  12. <ul>
  13. <li v-for="item in items" :key="item.id">{{ item.text }}</li> <!-- DIRECTIVA 2 v-for p/ iterar sobre elementos y mostrar el nombre -->
  14. </ul>
  15.  
  16.  
  17. <my-component></my-component>
  18.  
  19. </div>
  20.  
  21.  
  22. <template id="my-component">
  23. <div>{{ message2 }}</div>
  24. </template>
  25.  
  26.  
  27. <script>
  28. const app = Vue.createApp({
  29. data() {
  30. return {
  31. showtitulo: true,
  32. title: 'Hello this is Maca testing title',
  33. items: [
  34. { id: 0, text: 'cosa 1' },
  35. { id: 1, text: 'cosa 2' },
  36. { id: 2, text: 'cosa 3' }
  37. ]
  38. }
  39. }
  40. });
  41.  
  42. app.component('my-component', {
  43. template: '#my-component',
  44. data() {
  45. return {
  46. message2: 'This is my custom component! IS THIS WORKING?'
  47. }
  48. }
  49. });
  50.  
  51. app.mount('#app');
  52.  
  53. console.log('Mounted!');
  54. </script>
  55.  
  56.  
  57. </body>
  58. </html>
  59.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement