如何在Typescript中使用react-native-web

时间:2018-07-29 12:36:09

标签: typescript react-native react-native-web

我已经使用create-react-native-app创建了应用程序。我用来运行和进行生产构建的命令是:

"scripts": {
  "web": "react-scripts start",
  "build": "react-scripts build"
}

对于react native,我可以使用react-native-scripts-ts,但是如何使用react-native-web配置Typescript管道?

1 个答案:

答案 0 :(得分:0)

因此解决方案是使用:

    @page
@model Test.Pages.UserRoles.IndexModel

@{
    ViewData["Title"] = "Index";
}

<h2>Index</h2>

<p>
    <a asp-page="Create">Create New</a>
</p>
<table class="table">
    <thead>
        <tr>
            <th>
                @Html.DisplayNameFor(model => model.UserRole[0].Role)
            </th>
            <th>
                @Html.DisplayNameFor(model => model.UserRole[0].User)
            </th>
            <th></th>
        </tr>
    </thead>
    <tbody>
        @foreach (var item in Model.UserRole)
        {
            <tr>
                <td>
                    @Html.DisplayFor(modelItem => item.Role.RoleId)
                </td>
                <td>
                    @Html.DisplayFor(modelItem => item.User.UserName)
                </td>
                <td>
                    <a asp-page="./Edit" asp-route-id="@item.Id">Edit</a> |
                    <a asp-page="./Details" asp-route-id="@item.Id">Details</a> |
                    <a asp-page="./Delete" asp-route-id="@item.Id">Delete</a>
                </td>
            </tr>
        }
    </tbody>
</table>

并使用以下命令运行"scripts": { "test": "jest", "web": "react-scripts-ts start", "build": "react-native-scripts-ts build", "test:web": "react-scripts test --env=jsdom", "eject": "react-scripts eject" },

App.tsx