Skip to content

Instantly share code, notes, and snippets.

@FernandoBasso
Created July 1, 2017 13:44
Show Gist options
  • Save FernandoBasso/747a6d11138b82ec6c5ade8287c79264 to your computer and use it in GitHub Desktop.
Save FernandoBasso/747a6d11138b82ec6c5ade8287c79264 to your computer and use it in GitHub Desktop.
App Vue + TypeScript problem...
<script lang="ts">
import Vue from 'vue';
import Component from 'vue-class-component';
@Component({
// Renders just “title: ”...
template: '<div>title: {{ theTitle }}</div>'
})
export default class App extends Vue {
private _title: string;
constructor() {
super();
this._title = 'Original Title';
console.info(this._title); // 'Original Title'.
}
get theTitle (): string {
console.info(this._title); // undefined!!!!
return this._title;
}
};
</script>
@FernandoBasso
Copy link
Author

Problem found.

Properties that start with _ or $ will not be proxied on the Vue instance because they may conflict with Vue’s internal properties and API methods. You will have to access them as vm.$data._property.

https://vuejs.org/v2/api/#Options-Data

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment