按文档引入第三库有赞的 button 组件为例:
usingComponents: {
'van-button': '../../libs/vant-weapp/dist/button/index'
}
render 函数中如下使用时,ts 告警:
\
告警内容如下:
Property 'van-button' does not exist on type 'JSX.IntrinsicElements'.
现在为了忽略告警,代码如下所示:
{
// @ts-ignore
\
}
请问有更好的解决方式,或者正确的使用方式是什么?
添加 global.d.ts
如果需要类型可以自己定义。
declare namespace JSX {
interface IntrinsicElements {
van-button: any;
}
}
Most helpful comment
添加 global.d.ts
如果需要类型可以自己定义。