Skip to content

Tofu-Xx/setupin

Repository files navigation

English | ็ฎ€ไฝ“ไธญๆ–‡

๐Ÿ˜ What is a setupin?

setupin allows you to use Vue SFC syntax in HTML.

Using the sfc2esm, which compiled at runtime for esm vue code format, and dynamic execution.

๐Ÿคฏ Code comparison

esm.html

vue esm is complicated to write

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>esm</title>
  <style>
    button {
      font-size: larger;
    }
  </style>
</head>
<body>
  <div id="app">
    <button @click="count++">{{ count }}</button>
  </div>

  <script type="module">
    import { createApp, defineComponent, ref } from 'https://unpkg.com/vue/dist/vue.esm-browser.js';
    const App = defineComponent(() => {
      const count = ref(0);
      return {
        count
      };
    });
    createApp(App).mount('#app')
  </script>
</body>
</html>

setup.vue

vue sfc needs to be compiled

<script setup>
  import { ref } from 'vue'
  const count = ref(0)
</script>

<template>
  <button @click="count++">{{ count }}</button>
</template>

<style>
  button {
    font-size: larger;
  }
</style>

setupin.html

setupin brings it all together

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>setupin</title>
  <script src="https://unpkg.com/setupin"></script>
</head>

<script setup>
  import { ref } from 'vue'
  const count = ref(0)
</script>

<template>
  <button @click="count++">{{ count }}</button>
</template>

<style>
  button {
    font-size: larger;
  }
</style>

It's exactly the same as Vue SFC except for the <head>

๐Ÿค“ Characteristics

๐Ÿค” Why setupin

  1. Easy to learn Offer a friendly environment for beginners to easily grasp the core usage of Vue.
  2. Simple development Provide a convenient way to rapidly develop small webpage without complex configurations.
  3. Quick experience Allow users to quickly experiment with Vue's new features in HTML and feel its charm.

๐Ÿ˜ Playground

try it on stackblitz !

๐Ÿฅฐ Usage

<!-- The default is the dev version -->
<script src="https://unpkg.com/setupin"></script>

<!-- dev -->
<script src="https://unpkg.com/setupin/dist/main.js"></script>

<!-- prod -->
<script src="https://unpkg.com/setupin/dist/main.prod.js"></script>