Typescript Render 将按钮显示为文本而不是 HTML
Typescript Render showing button as text instead of HTML
我有一个打字稿文件,我在其中渲染一个简单的 hello world div。我可以呈现一个 HTML table,但是添加一个输入或一个按钮会呈现字面上的“”。
根据我的经验,我似乎缺少要导入的包。我在下面粘贴了我的导入和 Render() 函数:
import * as watchUtils from "esri/core/watchUtils";
import Handles = require("esri/core/Handles");
import { declared, property, subclass } from "esri/core/accessorSupport/decorators";
import MapView = require("esri/views/MapView");
import Widget = require("esri/widgets/Widget");
import { renderable, tsx } from "esri/widgets/support/widget";
render() {
if(resolvedValue != null){
selectedHasfolder = "<table >";
for(var i = 0; i < resolvedValue.length; ++i){
selectedHasfolder += "<tr><td><button >Select Inspection(s) to proceed.</button></td><td>" + resolvedValue[i]["PropertyA"] + "</td></tr>";
}
selectedHasfolder += "</table>";
}
return <div class="basemap23" style="background-color:#FFFFFF;" innerHTML={selectedHasfolder}></div>;
我建议你这样做,不要使用 innerHTML
。
function Component() {
const selectedHasFolder = resolvedValue ? (
<table>
{resolvedValue.map((item, index) => (
<tr key={index}>
<td>item.propertyA</td>
<td>
<button>Select Inspection(s) to proceed.</button>
</td>
</tr>
))}
</table>
) : null;
return (
<div class="basemap23" style="background-color:#FFFFFF;">
{selectedHasFolder}
</div>
);
}
我有一个打字稿文件,我在其中渲染一个简单的 hello world div。我可以呈现一个 HTML table,但是添加一个输入或一个按钮会呈现字面上的“”。
根据我的经验,我似乎缺少要导入的包。我在下面粘贴了我的导入和 Render() 函数:
import * as watchUtils from "esri/core/watchUtils";
import Handles = require("esri/core/Handles");
import { declared, property, subclass } from "esri/core/accessorSupport/decorators";
import MapView = require("esri/views/MapView");
import Widget = require("esri/widgets/Widget");
import { renderable, tsx } from "esri/widgets/support/widget";
render() {
if(resolvedValue != null){
selectedHasfolder = "<table >";
for(var i = 0; i < resolvedValue.length; ++i){
selectedHasfolder += "<tr><td><button >Select Inspection(s) to proceed.</button></td><td>" + resolvedValue[i]["PropertyA"] + "</td></tr>";
}
selectedHasfolder += "</table>";
}
return <div class="basemap23" style="background-color:#FFFFFF;" innerHTML={selectedHasfolder}></div>;
我建议你这样做,不要使用 innerHTML
。
function Component() {
const selectedHasFolder = resolvedValue ? (
<table>
{resolvedValue.map((item, index) => (
<tr key={index}>
<td>item.propertyA</td>
<td>
<button>Select Inspection(s) to proceed.</button>
</td>
</tr>
))}
</table>
) : null;
return (
<div class="basemap23" style="background-color:#FFFFFF;">
{selectedHasFolder}
</div>
);
}