GithubHelp home page GithubHelp logo

elemental-mind / class-based-vue3-ts-template Goto Github PK

View Code? Open in Web Editor NEW
3.0 2.0 0.0 12 KB

Write your Vue app with class-based components

HTML 15.87% Vue 71.53% TypeScript 12.60%
class-component template vue3 typescript vite vue-facing-decorator vue vue-class-component vuejs

class-based-vue3-ts-template's Introduction

A class based Vue 3 template

I was missing the class based syntax I was used to from Vue 2 where I heavily used vue-class-component.

This template sets you up so that you can write your components in such a fashion with Vue 3:

<template>
    <div class="container">
        <h1>{{ msg }}</h1>
        <button type="button" @click="increment()"> Counter is at: {{ count }}</button>
    </div>
</template>

<script lang="ts">
import { Component, Prop, Vue } from 'vue-facing-decorator';

@Component({ components: {  } })
export default class HelloWorld extends Vue 
{
    @Prop({default: "Default message!"}) 
    msg!: string;
    
    count = 0;
    
    increment()
    {
        this.count++;
    }
}
</script>

<style scoped>
    ...
</style>

This repo gives you a fresh start with class components in Vue 3 based on the awesome vue-facing-decorator-project. To learn more and get some code samples look here:

vue-facing decorator

Getting started

Pretty straighforward. Clone this repository, do an npm install and start your vite dev-server with npm run dev. Your app should be listening on localhost:3000.

A word on debugging

Initial setup

This repo is set up for VSCode and includes a launch.json configured to attach to a running edge instance launched with the --remote-debugging-port=9222 flag. I am working heavily with the Edge Tools for VSCode as they make the dev experience seamless - hence the setup.

Debugging issues with HMR

Vite's HMR breaks your breakpoints. Once you hit save and vite replaces a module your breakpoints will stop. To hit the breakpoints properly again you need to unfortunately do a full page reload. Then breakpoints work again until you do the next change. You can disable HMR in the vite config, hwever this is not an option for me and I found occasional reloading to be a bearable workaround.

class-based-vue3-ts-template's People

Contributors

elemental-mind avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.