typescript - 使用 Font Awesome 和 Vue 的 Typescript 构建错误
问题描述
我按照字体真棒网站上的说明在 Vue 中设置它们。在我的 main.ts 文件中,即使图标工作正常,我也会收到打字稿错误。
FunctionalComponentOptions 类型的参数
错误发生在 FontAwesomeIcon 上的这一行
Vue.component('font-awesome-icon', FontAwesomeIcon)
错误是“FunctionalComponentOptions,PropsDefinition>>”类型的参数不可分配给“ComponentOptions,DefaultMethods,DefaultComputed,PropsDefinition>,Record>”类型的参数。属性“渲染”的类型不兼容。
这是因为这个 index.d.ts 文件而发生的。如果我将它更改为任何它会工作。
declare module '@fortawesome/vue-fontawesome' {
import { FunctionalComponentOptions } from 'vue'
export const FontAwesomeIcon: FunctionalComponentOptions
export const FontAwesomeLayers: FunctionalComponentOptions
export const FontAwesomeLayersText: FunctionalComponentOptions
}
即使我使用来自(https://fontawesome.com/how-to-use/on-the-web/using-with/vuejs)的所有相同代码,我仍然会收到错误消息。
提前感谢您的帮助。
解决方案
推荐阅读
- javascript - 改变状态和重定向
- postgresql - 如果我已经使用 GIN 索引,如何优化查询
- javascript - 状态更新后 React useEffect 不会重新加载我的组件
- c++ - Rcpp 函数在打包时会导致 RStudio 崩溃
- c# - Linq过滤子类并返回父类?
- ibm-cloud - 无法在 bluemix 上为 cloudant db 创建凭证
- laravel - 如何连接 DocumentDB 和 Laravel
- c - 如何将更改写入结构单链表?
- python - 在多级关系的情况下,如何将 Django 模型对象/查询集作为字典获取?
- php - 如何将数组输入到 INSERT INTO 查询中?