1

The example on https://github.com/vuejs/vue-class-component (for the component syntax that's new in vuejs3) but I'm using straight type script instead of babel. I therefore tried:

<script lang="ts">
import Vue from "vue"
import Component from "vue-class-component"

@Component({
    props: {
        propMessage: String
    }
})
export default class MyComponent extends Vue {
    helloMsg = "Hello, " + this.propMessage

}
</script>

Unfortunately, this.propMessage can't be found. How do I have to change the syntax to make it found?

1
  • Despite the tag, this question is not related to vuejs3. Commented Jan 8, 2020 at 9:18

1 Answer 1

3

I would guess this.props.propMessage would work (but i can't test it right now) and you may have already tried.

I recommend you using @Prop decorator from vue-property-decorator which provide a clearer syntax on the long-end.

It would give something like :

@Component
export default class MyComponent extends Vue {
    @Prop() propMessage !: string;

    helloMsg = "Hello, " + this.propMessage;
}

Good luck

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.