DEV Community

Discussion on: An introduction to Vue 3 and Typescript - Getting started

Collapse
 
patarapolw profile image
Pacharapol Withayasakpunt • Edited

I don't what '''lang tag you use, but '''vue works

<script setup lang="ts">
import { ref, withDefaults, useSlots, useAttrs } from 'vue';

const props = withDefaults(
  defineProps<{
    msg: string;
  }>(),
  { msg: 'Hello World!' }
);

const emit = defineEmits<{
  (event: 'click', count: number): void;
}>();

const slots = useSlots();
const attributes = useAttrs()

const count = ref(0);
const increment = () => count.value++;
</script>

<template>
  <h1>{{ msg }}</h1>

  <button type="button" @click="increment">count is: {{ count }}</button>
  <p>
    Edit
    <code>components/HelloWorld.vue</code> to test hot module replacement.
  </p>
</template>
Enter fullscreen mode Exit fullscreen mode

Also, superb showcase. I think you missed showing <style scoped> and extra selectors, though. (But :host is still missing.)

Another thing about Vite, that it can also bundle libraries; as well as vanilla, and not-only-Vue (e.g. React). I haven't really tried, but Vue and React in the same project should also be possible.