首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在React jsx中访问xml命名空间

如何在React jsx中访问xml命名空间
EN

Stack Overflow用户
提问于 2020-08-21 16:00:04
回答 1查看 78关注 0票数 0

我在index.html中使用过xml名称空间,如下所示。

代码语言:javascript
复制
<html xmlns:v="urn:schemas-microsoft-com:vml"
xmlns:o="urn:schemas-microsoft-com:office:office"
xmlns:w="urn:schemas-microsoft-com:office:word"
xmlns:m="http://schemas.microsoft.com/office/2004/12/omml"
xmlns="http://www.w3.org/TR/REC-html40">

如何在jsx代码中访问这些属性?正如它所说的,这些属性是未定义的。

代码语言:javascript
复制
<p class=MsoNormal>
<span class=subheader1>
<span style='font-size:13.0pt'></span>
</span>
<span style='font-size:12.0pt;font-family:"Arial",sans-serif'><o:p></o:p></span></p>
EN

回答 1

Stack Overflow用户

发布于 2020-11-24 13:01:18

你为什么需要它?但以下内容可能会对您有所帮助:

代码语言:javascript
复制
render(){
  return (
    <div attr={document.children[0].attributes['xmlns:w'].value}>
      <div>{document.children[0].attributes['xmlns:o'].value}<div>
    <div>
  )
}

document.children[0]是当前html页面的html标记。I希望这能对你有所帮助。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/63518869

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档