如何在React/JSX组件中使用Slider Revolution标签名称?

huangapple go评论70阅读模式
英文:

How to use Slider Revolution tag names in a React / JSX component?

问题

我有以下组件:

```es6
export default function Home() {
	return (
		<main className="site-main">
			<rs-fullwidth-wrap
				id="rev_slider_2_1_forcefullwidth"
				style={{ marginTop: '0px', marginBottom: '0px' }}
			>

得到了以下错误:

> 类型 'JSX.IntrinsicElements' 上不存在属性 'rs-fullwidth-wrap'。

我尝试在 return 前添加以下代码:

declare namespace JSX {
	interface IntrinsicElements {
		'rs-fullwidth-wrap': any
		'rs-module-wrap': any
	}
}

但没有帮助。还能做什么?


<details>
<summary>英文:</summary>

I have following coponent:

```es6
export default function Home() {
	return (
		&lt;main className=&quot;site-main&quot;&gt;
			&lt;rs-fullwidth-wrap
				id=&quot;rev_slider_2_1_forcefullwidth&quot;
				style={{ marginTop: &#39;0px&#39;, marginBottom: &#39;0px&#39; }}
			&gt;

got this:

> Property 'rs-fullwidth-wrap' does not exist on type 'JSX.IntrinsicElements'.

I tried to add this before return

declare namespace JSX {
	interface IntrinsicElements {
		&#39;rs-fullwidth-wrap&#39;: any
		&#39;rs-module-wrap&#39;: any
	}
}

Did not help. What else I can do?

答案1

得分: 0

你的声明是不正确的,请尝试这样写:

declare global {
  namespace JSX {
    interface IntrinsicElements {
      "rs-fullwidth-wrap": JSX.IntrinsicElements["div"];
    }
  }
}
英文:

Your declaration is incorrect, try this:

declare global {
  namespace JSX {
    interface IntrinsicElements {
      &quot;rs-fullwidth-wrap&quot;: JSX.IntrinsicElements[&quot;div&quot;];
    }
  }
}

huangapple
  • 本文由 发表于 2023年6月13日 18:43:12
  • 转载请务必保留本文链接:https://go.coder-hub.com/76464062.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定