This repository has been archived by the owner on Feb 7, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 379
Computed attributes #85
Comments
As mentioned in this tutorial, computed properties are implemented in vue-property-decorator as ES6 getters: @Component
export default class App extends Vue {
get myComputedProp() {
return Math.random()
}
} Which is equal to this plain Vue syntax: export default {
computed: {
myComputedProp() {
return Math.random()
}
}
} |
What about setters? |
Hi. @Component
export default class App extends Vue {
set myComputedProp(value: any) {
console.log(value)
}
} |
What about two-way computed properties (with get and set) in TypeScript. I absolutely do not find any example on this |
Would be great to add computed attributes examples to the documentation. |
Converting from getters / setters into computed properties is provided by @Component
class YourComponent extends Vue {
firstname = ''
lastname = ''
get value() {
return `${this.firstname} ${this.lastname}`
}
set value(fullname: string) {
const [firstname, lastname] = fullname.split(' ')
this.firstname = firstname
this.lastname = lastname
}
} |
How to use |
It'll be supported if the Vue itself does. |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
How can I use computed attributes with decorators?
Thanks!
The text was updated successfully, but these errors were encountered: