Taro: 小程序引入第三方库的组件,render 中使用组件元素标签时 ts 告警

Created on 11 Nov 2018  ·  1Comment  ·  Source: NervJS/taro

按文档引入第三库有赞的 button 组件为例:
usingComponents: {
'van-button': '../../libs/vant-weapp/dist/button/index'
}

render 函数中如下使用时,ts 告警:
\

告警内容如下:
Property 'van-button' does not exist on type 'JSX.IntrinsicElements'.

现在为了忽略告警,代码如下所示:
{
// @ts-ignore
\
}

请问有更好的解决方式,或者正确的使用方式是什么?

Most helpful comment

添加 global.d.ts

如果需要类型可以自己定义。

declare namespace JSX {
  interface IntrinsicElements {
    van-button: any;
  }
}

>All comments

添加 global.d.ts

如果需要类型可以自己定义。

declare namespace JSX {
  interface IntrinsicElements {
    van-button: any;
  }
}
Was this page helpful?
0 / 5 - 0 ratings