1

Just as the title, @Prop validator via reflect-metadata does not work after refreshing the page.

As the doc says, I import reflect-metadata and turn emitDecoratorMetadata to true.

And my code is just like this:

<template>
    <div>
        <HelloWorld :msg="123"></HelloWorld>
    </div>
</template>
import {Vue, Component, Prop} from 'vue-property-decorator';

@Component({})
export default class HelloWorld extends Vue {
    @Prop() readonly msg!: string;
}
// [Vue warn]: Invalid prop: type check failed for prop "msg". 
// Expected String with value "123", got Number with value 123.

Surely it works when the first time I enter the page. But when I refresh the page, it does not work (It does not validate prop's type, both dev env and prod env). And I'm sure that I only import reflect-metadata once, and I have updated reflect-metadata to the latest version 0.1.13 (because I heard the older version has some 'unintended behavior').

I tried to import reflect-metadata in the dependency (sorry to modify dependency's code), and this time it works, even after refreshing. Why?

And I found something strange......After refreshing the page, the Reflect.getMetadata function will disappear. Is this something wrong with Reflect?

Wen Sun
  • 11
  • 3

0 Answers0