我正在使用带有打字稿的vue composition api。
如何使用打字稿打字系统强烈打字道具道具?
如官方docs中所述,您可以通过两种方式输入道具:
通过参数注释定义农作物
import { defineComponent } from 'vue'
export default defineComponent((props: { foo: string }) => {
props.foo
})
或类似这样
import { defineComponent } from 'vue'
export default defineComponent({
props: {
foo: String
},
setup(props) {
props.foo // <- type: string
}
})