All Projects → nuxt-community → Nuxt Property Decorator

nuxt-community / Nuxt Property Decorator

Licence: mit
Property decorators for Nuxt (base on vue-property-decorator)

Programming Languages

javascript
184084 projects - #8 most used programming language

Labels

Projects that are alternatives of or similar to Nuxt Property Decorator

nuxt-express
Creating isomorphic web applications with Nuxt and Express.
Stars: ✭ 20 (-93.17%)
Mutual labels:  nuxt
test-utils
Test utilities for Nuxt.js
Stars: ✭ 100 (-65.87%)
Mutual labels:  nuxt
Create Nuxt App
Create Nuxt.js App in seconds.
Stars: ✭ 3,126 (+966.89%)
Mutual labels:  nuxt
nuxt-blog
📝 Personal blog built with Nuxt.js and wordpress rest api
Stars: ✭ 13 (-95.56%)
Mutual labels:  nuxt
nuxt-storyblok-queries
Nuxt.js module to simplify queries to the Storyblok API
Stars: ✭ 17 (-94.2%)
Mutual labels:  nuxt
nuxt-star-admin-extra
Admin Template base on Vue StarAdmin with improved on design and served using Nuxt.js
Stars: ✭ 19 (-93.52%)
Mutual labels:  nuxt
picty
Simple Image Viewer based on Electron
Stars: ✭ 17 (-94.2%)
Mutual labels:  nuxt
Nuxt Blog
基于Nuxt.js服务器渲染(SSR)搭建的个人博客系统
Stars: ✭ 277 (-5.46%)
Mutual labels:  nuxt
nuxt-styleguide
Increase the quality and efficiency of product design and development workflows
Stars: ✭ 15 (-94.88%)
Mutual labels:  nuxt
Nuxt Webfontloader
Efficient web font loading has never been easier!
Stars: ✭ 264 (-9.9%)
Mutual labels:  nuxt
nuxt wp
Repo for my blog series on a building a site with WordPress REST API, Vue, and Nuxt.js
Stars: ✭ 41 (-86.01%)
Mutual labels:  nuxt
LiveWallpaper
A tiny win10 (dynamic) wallpaper changer | 巨应壁纸 | 动态壁纸 | Free wallpaper engine
Stars: ✭ 396 (+35.15%)
Mutual labels:  nuxt
I Hate Regex
The code for iHateregex.io 😈 - The Regex Cheat Sheet
Stars: ✭ 3,176 (+983.96%)
Mutual labels:  nuxt
k-domains
A simple module to manage multiple subdomains with just one project
Stars: ✭ 41 (-86.01%)
Mutual labels:  nuxt
Frontend Boilerplates
Collection of Boilerplates with ES6, Vue, React, Nuxt, TypeScript, SCSS, Nodejs. Using good practices and file structures to inspire your real projects.
Stars: ✭ 269 (-8.19%)
Mutual labels:  nuxt
global-components
Module to register global components for Nuxt.js
Stars: ✭ 57 (-80.55%)
Mutual labels:  nuxt
admin-null-nuxt
Admin Null — Free Nuxt Bulma Admin Dashboard (with dark mode)
Stars: ✭ 39 (-86.69%)
Mutual labels:  nuxt
Nuxt7
📱 Full Featured iOS & Android PWA Apps with Nuxt.js and Framework7
Stars: ✭ 282 (-3.75%)
Mutual labels:  nuxt
Nuxt Ssr Firebase
Nuxt.js Universal App with SSR via Firebase Functions and Firebase Hosting
Stars: ✭ 273 (-6.83%)
Mutual labels:  nuxt
N2ex
🌈 V2ex built with Nuxt.js (vue&ssr)
Stars: ✭ 260 (-11.26%)
Mutual labels:  nuxt

Nuxt Property Decorator


Handy ES / TypeScript decorators for class-style Vue components in Nuxt (based on Vue class component) and Property decorators for Vue (bases on Vue Property Decorator) and Vuex (based on Vuex Class)

This library fully depends on vue-class-component.

License

MIT License

Install

Installation is very easy

npm i -S nuxt-property-decorator

or

yarn add nuxt-property-decorator

Nuxt JS Instructions

It works out of the box with Nuxt JS.

Nuxt TS Instructions

It works out of the box with Nuxt TS.

Decorators and helpers

There are following decorators:

Other exports

  • namespace
  • mixins
  • Vue

Hooks

Vue Router hooks

  • beforeRouteEnter
  • beforeRouteUpdate
  • beforeRouteLeave

Nuxt hooks

  • asyncData
  • fetch
  • fetchOnServer
  • head
  • key
  • layout
  • loading
  • middleware
  • scrollToTop
  • transition
  • validate
  • watchQuery
  • meta

Vue-class Hooks

  • data
  • beforeCreate
  • created
  • beforeMount
  • mounted
  • beforeDestroy
  • destroyed
  • beforeUpdate
  • updated
  • activated
  • deactivated
  • render
  • errorCaptured
  • serverPrefetch

Usage

import {
  Component,
  Inject,
  Model,
  Prop,
  Provide,
  Vue,
  Watch,
} from "nuxt-property-decorator"

const s = Symbol("baz")

@Component({
  components: { comp },
})
export class MyComponent extends Vue {
  @Inject() foo!: string
  @Inject("bar") bar!: string
  @Inject(s) baz!: string

  @Model("change") checked!: boolean

  @Prop()
  propA!: number

  @Prop({ default: "default value" })
  propB!: string

  @Prop([String, Boolean])
  propC!: string | boolean

  @Prop({ type: null })
  propD!: any

  @Provide() foo = "foo"
  @Provide("bar") baz = "bar"

  @Watch("child")
  onChildChanged(val: string, oldVal: string) {}

  @Watch("person", { immediate: true, deep: true })
  onPersonChanged(val: Person, oldVal: Person) {}

  beforeRouteLeave(to, from, next) {
    // called when the route that renders this component is about to
    // be navigated away from.
    // has access to `this` component instance.
  }
}

is equivalent to

const s = Symbol("baz")

export const MyComponent = Vue.extend({
  name: "MyComponent",
  components: { comp },
  inject: {
    foo: "foo",
    bar: "bar",
    [s]: s,
  },
  model: {
    prop: "checked",
    event: "change",
  },
  props: {
    checked: Boolean,
    propA: Number,
    propB: {
      type: String,
      default: "default value",
    },
    propC: [String, Boolean],
    propD: { type: null },
  },
  data() {
    return {
      foo: "foo",
      baz: "bar",
    }
  },
  provide() {
    return {
      foo: this.foo,
      bar: this.baz,
    }
  },
  methods: {
    onChildChanged(val, oldVal) {},
    onPersonChanged(val, oldVal) {},
  },
  beforeRouteLeave(to, from, next) {
    // called when the route that renders this component is about to
    // be navigated away from.
    // has access to `this` component instance.
  },
  watch: {
    child: {
      handler: "onChildChanged",
      immediate: false,
      deep: false,
    },
    person: {
      handler: "onPersonChanged",
      immediate: true,
      deep: true,
    },
  },
})

As you can see at propA and propB, the type can be inferred automatically when it's a simple type. For more complex types like enums you do need to specify it specifically. Also this library needs to have emitDecoratorMetadata set to true for this to work.

Useful links

See also:

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].