有人知道如何正确地告诉TypeScript如何了解我在第一张照片上授权的Prop
的{{1}}吗?
type
为Prop
。 image 1 engine
<script lang="ts">
import Vue from 'vue';
import { Component, Prop, Watch, Mixins } from 'vue-property-decorator';
import pDebounce from 'p-debounce';
// Define the props by using Vue's canonical way.
export const FetcherProps = Vue.extend({
props: {
engine: Function
}
})
// Use defined props by extending GreetingProps
@Component
class Fetcher extends FetcherProps {
response: Array<any> | Promise<any> = [];
fetch2: Function;
// @Prop() engine!: Function;
// @Prop({ default: null }) debounce!: null | number;
// @Prop({ default: () => {} }) request!: Dictionary<any>;
// @Prop({ default: true }) promisify!: boolean;
get requestObject() {
return { params: this.request };
}
@Component({})
class EmSearchEngine extends Fetcher {
在此之前,我尝试在仓库中使用示例文件夹中的一个示例:https://github.com/vuejs/vue-class-component/blob/master/example/src/App.vue,但这对我没有帮助。
我的代码有问题吗?还是我必须在
render(h: CreateElement) {
return h(Fetcher, {
props: {
debounce: 300,
promisify: false,
engine: this.engine <-- "TS2339: Property 'engine' does not exist on type 'EmSearchEngine'.,
request: {
...this.initialQuery,
...this.query,
cancelToken: new CancelToken((cancel) => {
abortSearch = cancel;
})
}
组件上明确声明engine
类的属性?
在此先感谢您的帮助。原始github的问题:https://github.com/vuejs/vue-class-component/issues/391