报错

修改后代码如下:

`

type.ts文件代码片段如下:

import { SchemaRefs } from 'ajv/dist/compile'

import { PropType } from 'vue'

export enum SchemaTypes {

'NUMBER' = 'number',

'INTEGER' = 'intrger',

'STRING' = 'string',

'OBJECT' = 'object',

'ARRSY' = 'array',

'BOOLEAN' = 'boolean',

}

type SchemaRef = { $ref: string } // 预先定义 可以使用$ref引用schema

// type Schema = any

export interface Schema {

type: SchemaTypes | string // 加上string有利于类型的校验 要不然只能用SchemaTypes.NUMBER来使用类型

const?: any

format?: string

default?: any

properties?: {

[key: string]: Schema | { $ref: string }

}

items?: Schema | Schema[] | SchemaRefs

dependencies?: {

[key: string]: string[] | Schema | SchemaRef

}

oneOf?: Schema[]

anyOf?: Schema[]

allOf?: Schema[]

// vjsf?: VueJsonSchemaConfig

required?: string[]

enum?: any[]

enumKeyValue?: any[]

additionalProperties?: any

additionalItems?: Schema

}

export const FiledPropsDfine = {

schema: {

type: Object as PropType,

required: true,

},

value: {

required: true,

},

onChange: {

type: Function as PropType<(v: any) => void>,

required: true,

},

rootSchema: {

type: Object as PropType,

required: true,

},

} as const

主要问题就是说script标签中加上setup,代码块中不能再出现export default关键字,将该部分代码

export default {

props: FiledPropsDfine,

}

declare const props: {

// 向ts声明props的定义

value: any

onChange: (v: string) => void

schema: Schema

}

修改为:

declare const props: FiledPropsDfine & {

// 向ts声明props的定义

value: any

onChange: (v: string) => void

schema: Schema

}

相关阅读

评论可见,请评论后查看内容,谢谢!!!评论后请刷新页面。