create a petite-vue app in javascript

To create a Petite-Vue app in JavaScript, you can follow these steps:

  1. Start by creating an HTML file with a root element where the app will be mounted. You can name it whatever you want, like index.html.
<!DOCTYPE html>
<html>
<head>
  <meta charset="UTF-8">
  <title>My Petite-Vue App</title>
</head>
<body>
  <div id="app">
    <!-- Your app will be mounted here -->
  </div>
  <script src="https://unpkg.com/petite-vue@next"></script>
  <script src="app.js"></script>
</body>
</html>
283 chars
15 lines
  1. Next, create a JavaScript file, like app.js, where you will define your app. In this file, you'll first create a ViewModel with Petite-Vue:
index.tsx
const vm = PetiteVue.createApp({
  data() {
    return {
      message: 'Hello, Petite-Vue!',
    }
  },
})
108 chars
8 lines

This ViewModel has a data property with an object that contains the message that will be displayed in the app. You can add more properties as needed.

  1. Then, mount the ViewModel to your root element:
index.tsx
vm.mount('#app')
17 chars
2 lines

This will render your app inside the root element with the id of app.

  1. Test your app by running your HTML file in a browser. You should see your message displayed on the page.
<div id="app">
  <p>{{ message }}</p>
</div>
45 chars
4 lines

That's it! You now have a basic Petite-Vue app in JavaScript. You can add more components and functionality as needed.

gistlibby LogSnag