npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@vuets/class

v1.1.9

Published

typescript vue classes

Downloads

12

Readme

@vuets/class

This library fully depends on vue-class-component vue Part of the way to learn from vue-property-decorator

npm (scoped with tag)

Version

  1. In vscode html5 tag autocomplate attribute
  2. Autocomplate PropTypes hint

install

npm i @vuets/class vue vue-class-component vue-property-decorator

Usage

From vue-class-component usage

Example

import Vue from '@vuets/class'
import { Component } from 'vue-property-decorator'
@Component
export default class extends Vue {
  private render() {
      return (
          <div>
              <Test />
          </div>
      )
  }
}

If you need type hints

Example TSX

interface PropTypes {
  title?: string;
  mode: 1 | 2 | 3;
}

import Vue from '@vuets/class'
import { Component } from 'vue-property-decorator'
@Component
export default class extends Vue<PropTypes> {
  private render() {
      return (
          <div>
              <Test />
          </div>
      )
  }
}

Example TS

import Vue from '@vuets/class'
import { Component } from 'vue-property-decorator'

interface PropTypes {
  title?: string;
  mode: 1 | 2 | 3;
}

@Component({
  template: require('./any.html')
})
export default class extends Vue<PropTypes> {}

If you use webpack, maybe need raw-loader handler html file

Decorators

See vue-property-decorator, Similar vue-property-decorator, Api Please see index.d.ts

1. @Props(propType?: PropOptions)

vue props option:

{
    props: {
      size: {
          type: Number,
          default: 100
      },
      type: Number,
      age: {
        type: Number,
        required: true
      },
      title: {
        type: String,
        validator: (value) => typeof value === 'string'
      }
    }
}

For typescript:

Example

import Vue from '@vuets/class'
import { Component, Prop } from 'vue-property-decorator'

@Component
export default class extends Vue<PropTypes>{
  @Prop({type: Number, default:100}) size!:number;
  @Prop(Number) type!:number;
  @Prop({type: Number, required:true}) age!:number;
  @Prop({ type: String, validator: (value) => typeof value === 'string' }) public title!: string;
}

2. @Model(event?: string | undefined, propType?: PropOptions)

vue props option:

props: {
  checked: {
    type: Boolean
  },
  model: {
    prop: 'checked',
    event: 'change'
  }
}

For typescript:

Example

import Vue from '@vuets/class'
import { Component, Model } from 'vue-property-decorator'

@Component
export default class extends Vue<PropTypes>{
  @Model('change',String) checked!: string;
}

3. @Watch(watchKey: string, option?: WatchOptions | undefined)

vue props option:

{
  watch: {
    a(n: boolean, o: boolean){
       console.log(n)
    },
    b: {
      handler: (n: object, o: object)=> console.log(n),
      deep: true
    }
  }
}

For typescript:

Example

import Vue from '@vuets/class'
import { Component, Watch } from 'vue-property-decorator'

@Component
export default class extends Vue<PropTypes>{
  public a:boolean = false;
  public b:object = {}
  @Watch('a')
  aWatching(n: boolean, o: boolean):void {
    console.log(n)
  }
  @Watch('b', { deep:true })
  bWatching(n: object, o: object):void {
    console.log(n)
  }
}

4. @Emit(event: string)

vue props option:

{
  methods: {
    run(n: number){
      this.$emit('click', n)
    }
  }
}

For typescript:

Example

import Vue from '@vuets/class'
import { Component, Emit } from 'vue-property-decorator'

export default class extends Vue<PropTypes>{
    @Emit('click')
    run(n: number) {}
}

5. @Provide(propertyKey?: string | symbol | undefined)

vue props option:

{
  data(){
    return {
      title: 'Im title',
      test: 'Im test'
    }
  },
  provide:{
    title: this.title,
    foo: this.test
  }
}

For typescript:

Example

import Vue from '@vuets/class'
import { Component, Provide } from 'vue-property-decorator'

export default class extends Vue<PropTypes>{
  @Provide() title:string = 'Im title';
  @Provide('test') test:string = 'Im test'
}

6. Inject(options?: string | symbol | InjectOptions | undefined)

vue props option:

{
  inject:{
    title: 'title'
    test:{
      from: 'foo',
      default: 'test data'
    }
  },
  template: `<h1>{{title}} {{this.test}}</h1>`
}

For typescript:

Example

import Vue from '@vuets/class'
import { Component, Inject } from 'vue-property-decorator'

export default class extends Vue<PropTypes>{
  @Inject() title!: string;
  @Inject({ from:'foo', default: 'test data' }) test!: string;
  render() {
  	return(
    	<h1>{this.title} {this.test}</h1>
    )    
  }
}

License

MIT License