【发布时间】:2021-06-30 14:00:11
【问题描述】:
import React, { useState, useEffect } from 'react'
import "./MainText.css"
import "./App.css";
import FormatColorFillIcon from '@material-ui/icons/FormatColorFill';
import BorderColorIcon from '@material-ui/icons/BorderColor';
function MainText() {
function enableEditMode() {
textPart.document.designMode = 'On';
}
useEffect(() => {
enableEditMode();
}, [])
return (
<div className="mainText">
<div className="mainText__second">
<iframe name="textPart" frameBorder="0" ></iframe>
</div>
</div>
)
我只显示了我没有得到结果的代码的主要部分。 我想访问 iframe 标记的 name 属性,但它显示 textPart 未定义。 我还尝试将 id 放入 iframe 并执行 document.getElementById 但它也不起作用。 帮帮我。
【问题讨论】:
标签: javascript html reactjs iframe react-hooks