带打字稿的vue-class-component语法

时间:2020-01-08 09:02:04

标签: vue.js vue-component vuejs3

https://github.com/vuejs/vue-class-component上的示例(适用于vuejs3中新的组件语法),但我使用的是纯文字脚本而不是babel。因此,我尝试了:

FutureBuilder

很遗憾,找不到builder: (BuildContext context, AsyncSnapshot snapshot) { if(snapshot.hasData){ // <-- check this before using data. true if it has data false if null. } else { } } 。我该如何更改语法才能使其找到?

1 个答案:

答案 0 :(得分:3)

我想this.props.propMessage可以工作(但是我现在无法测试),您可能已经尝试过了。

我建议您使用vue-property-decorator中的@Prop装饰器,以提供更清晰的长语法。

它会给出类似的内容:

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

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

祝你好运