找不到模块vueform.config

问题描述 投票:0回答:1

我正在尝试在我的项目中使用 Vueforms,但我只是将其安装代码复制粘贴到我的

.ts
.js
文件中,但当我尝试导入 vueformconfig 和 builderconfig 时遇到错误

这是我的

main.ts
文件:

import { createApp } from 'vue'
import './style.css'
import App from './App.vue'
import Vueform from '@vueform/vueform'
import vueformConfig from './../vueform.config'
import Builder from '@vueform/builder'
import builderConfig from './../builder.config'


const app = createApp(App)
app.use(Vueform, vueformConfig)
app.use(Builder, builderConfig)
app.mount('#app')

这是来自 Typescript 转译器的错误消息:

src/main.ts:5:27 - error TS2307: Cannot find module './../vueform.config' or its corresponding type declarations.


src/main.ts:7:27 - error TS2307: Cannot find module './../builder.config' or its corresponding type declarations.

我浏览了很多网站和论坛来寻求修复,但我找不到任何一个,我有点被困在这里

编辑:

我使用 Vite+Vue 作为我的构建工具,我应该使用

main.ts
作为文件来创建 vue 应用程序并调用 vueformconfig 和 builderconfig 等所需的导入

编辑2:

我尝试将

vueform.config
的导入语句更改为
vueform.config.ts
,并对
builder.config

执行相同操作
import vueformConfig from './../vueform.config.ts'
import builderConfig from './../builder.config.ts'

这似乎解决了导入语句的问题,但我在

app.use()
行遇到错误。

const app = createApp(App)
app.use(Vueform, vueformConfig) //error1
app.use(Builder, builderConfig) //error2
app.mount('#app')

错误信息:

src/main.ts:11:9 - error TS2769: No overload matches this call.
  Overload 1 of 2, '(plugin: Plugin<[any]>, options_0: any): App<Element>', gave the following error.
    Argument of type 'typeof import("C:/Users/aryan/OneDrive/Documents/GitHub/spacious-forms/node_modules/@vueform/vueform/types/index")' is not assignable to parameter of 
type 'Plugin<[any]>'.
  Overload 2 of 2, '(plugin: Plugin<any>, options: any): App<Element>', gave the following error.
    Argument of type 'typeof import("C:/Users/aryan/OneDrive/Documents/GitHub/spacious-forms/node_modules/@vueform/vueform/types/index")' is not assignable to parameter of 
type 'Plugin<any>'.

11 app.use(Vueform, vueformConfig)
           ~~~~~~~


src/main.ts:12:9 - error TS2769: No overload matches this call.
  Overload 1 of 2, '(plugin: Plugin<[BuilderConfig]>, options_0: BuilderConfig): App<Element>', gave the following error.
    Argument of type 'typeof import("C:/Users/aryan/OneDrive/Documents/GitHub/spacious-forms/node_modules/@vueform/builder/index")' is not assignable to parameter of type 'Plugin<[BuilderConfig]>'.
  Overload 2 of 2, '(plugin: Plugin<BuilderConfig>, options: BuilderConfig): App<Element>', gave the following error.
    Argument of type 'typeof import("C:/Users/aryan/OneDrive/Documents/GitHub/spacious-forms/node_modules/@vueform/builder/index")' is not assignable to parameter of type 'Plugin<BuilderConfig>'.

12 app.use(Builder, builderConfig)
           ~~~~~~~

编辑2: 由于另一个人询问了项目结构,这是

spacious-forms
|
|____vueform.config.ts
|
|____builder.config.ts
|
|____src
|    |
|    |__ main.ts

typescript vue.js config
1个回答
0
投票

尝试像这样导入文件:

import vueformConfig from '../vueform.config.ts'
import builderConfig from '../builder.config.ts'
© www.soinside.com 2019 - 2024. All rights reserved.