由网友(在巴黎塔顶看东京樱花雨)分享简介:我要实现的目标在TypeScrip Gatsby中使用‘Gatsby-plugin-暗模式’我到目前为止所做的通过以下方式安装‘Gatsby-plugin-Dark-mode’yarn add gatsby-plugin-dark-mode在Gatsby-config.js中包含‘Gatsby-plugin-D...![条码软件如何在PDF的指定页中添加条形码 脚本编程](https://p.xsw88.cn/allimgs/daicuo/20230903/2007.png)
我要实现的目标
在TypeScrip Gatsby中使用‘Gatsby-plugin-暗模式’
我到目前为止所做的
通过以下方式安装‘Gatsby-plugin-Dark-mode’yarn add gatsby-plugin-dark-mode
在Gatsby-config.js中包含‘Gatsby-plugin-Dark-mode’
module.exports = {
plugins: ['gatsby-plugin-dark-mode'],
}
定义ThemeToggler组件并导入‘Gatsby-plugin-Dark-mode’
import React from 'react'
import { ThemeToggler } from 'gatsby-plugin-dark-mode'
class MyComponent extends React.Component {
render() {
return (
<ThemeToggler>
{({ theme, toggleTheme }) => (
<label>
<input
type="checkbox"
onChange={e => toggleTheme(e.target.checked ? 'dark' : 'light')}
checked={theme === 'dark'}
/>{' '}
Dark mode
</label>
)}
</ThemeToggler>
)
}
}
然后...
Could not find a declaration file for module 'gatsby-plugin-dark-mode'. '/Desktop/my-blog/gatsby-casper/node_modules/gatsby-plugin-dark-mode/index.js' implicitly has an 'any' type.
我想问的问题&帮助(&A)
我是不是忽略了什么?? TyepSCRIPT Gatsby是否不支持‘Gatsby-plugin-Dark-mode’?? 如果可以在TyepSCRIPT Gatsby中使用‘Gatsby-plugin-Dark-mode’,请告诉我这里遗漏了什么。推荐答案
![条码软件如何在PDF的指定页中添加条形码 脚本编程](https://p.xsw88.cn/allimgs/daicuo/20230903/2007.png)
如果您尚未创建,请在项目根目录中创建一个名为global.d.ts
的全局接口文件,然后添加以下内容:
declare module 'gatsby-plugin-dark-mode';
您可以将此代码段用于引发该错误且没有已发布类型的任何包。
相关推荐
最新文章