【发布时间】:2021-01-07 03:47:44
【问题描述】:
如您所知,从 Vue 3 开始,组件可以用 TypeScript 编写:
/// modal.vue
<template>
<div class="modal"></div>
</template>
<script lang="ts">
import { defineComponent } from "vue";
export default defineComponent({
name: "Modal",
props: {
foo: String,
bar: String
},
mounted() {
this.$props.foo // how to type `this` out of this context?
}
});
</script>
我的问题是如何从defineComponent 函数中输入 vue 实例?
/// another ts file.
let modal:???; // what the `???` should be?
modal.$props.foo // infer `$props.foo` correctly
【问题讨论】:
标签: typescript vue.js