index.js 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. import Template from "./templates/template.pupper";
  2. import { defineComponent } from "@pupperjs/renderer";
  3. import ImportedComponent from "./templates/ImportedComponent.pupper";
  4. import ExportedComponent from "./templates/ExportedComponent.pupper";
  5. (async function() {
  6. const pupper = defineComponent({
  7. render: Template,
  8. methods: {
  9. onClickPuppy(puppy) {
  10. alert("You clicked puppy " + puppy.id + "! :D");
  11. }
  12. },
  13. data: {
  14. page: {
  15. title: "pupper.js is awesome!",
  16. description: "I use pupper.js because I love puppies!",
  17. lead: "Also we love puppers, shiberinos and other doggos too! 🐶"
  18. },
  19. puppies: [
  20. {
  21. id: 1,
  22. title: "A cutie pup",
  23. description: "Look at this cutie",
  24. thumbnail: "https://placedog.net/800",
  25. properties: ["beautiful", "doge"]
  26. },
  27. {
  28. id: 2,
  29. title: "Another cute pup",
  30. description: "Isn't it a cute doggo?!",
  31. thumbnail: "https://placedog.net/400",
  32. properties: ["wow", "much woof"]
  33. }
  34. ]
  35. }
  36. });
  37. window.component = pupper;
  38. await pupper.mount(document.getElementById("app"));
  39. pupper.puppies.push({
  40. id: 3,
  41. title: "Wow, a shibe!",
  42. description: "Cute shiberino!!!",
  43. thumbnail: "https://media.istockphoto.com/photos/happy-shiba-inu-dog-on-yellow-redhaired-japanese-dog-smile-portrait-picture-id1197121742?k=20&m=1197121742&s=170667a&w=0&h=SDkUmO-JcBKWXl7qK2GifsYzVH19D7e6DAjNpAGJP2M=",
  44. shibe: true
  45. });
  46. ExportedComponent.mount(pupper.$slots.slot);
  47. ImportedComponent.mount(pupper.$slots.slot2);
  48. }());