当前位置: 首页 > 知识库问答 >
问题:

在ASP.NET内核中捆绑Typescript

艾哲
2023-03-14
[
  {
    "outputFileName": "wwwroot/js/vehicles.jsx",
    "inputFiles": 
     [
       "built/Components/General/VehiclePanel.jsx",
       "built/Components/Vehicles/VehiclePage.jsx"
     ],
     "minify": 
     {
       "enabled": false,
       "renameLocals": false
     },
  },
  {
    "outputFileName": "wwwroot/js/editVehicle.jsx",
    "inputFiles": 
     [
       "built/Components/General/Job.jsx",
       "built/Components/General/History.jsx",
       "built/Components/General/EditVehiclePanel.jsx",
       "built/Components/Vehicles/EditVehiclePage.jsx"
     ],
     "minify": 
     {
       "enabled": false,
       "renameLocals": false
     },
  },
  {
    "outputFileName": "wwwroot/js/editService.jsx",
    "inputFiles": 
     [
       "built/Components/General/Job.jsx",
       "built/Components/General/History.jsx",
       "built/Components/General/ServicePanel.jsx",
       "built/Components/Services/ServicePage.jsx"
     ],
     "minify": 
     {
       "enabled": false,
       "renameLocals": false
     },
  },
]
// Name History.tsx
// Author: Redacted
// CreatedDate: 24/02/2020
// ModifiedDate: 29/02/2020
// Description: History panel
import { Component } from 'react';
import { IHistory } from "../../Interfaces/Interfaces";

interface HistoryProps {
    history: IHistory;
}

export class History extends Component<HistoryProps> {

    constructor(props) {
        super(props);
    }

    render() {
        return (
            <div>
                <div className="box">
                    <div className="box-header with-border">
                        <h3 className="box-title">{this.props.history.title}</h3><div className="box-tools pull-right">{this.props.history.createdDateTime}</div>
                    </div>
                    <div className="box-body">
                        {this.props.history.description.split("\n").map(function (history, i) { return <p key={"h" + i}>{history}</p> })}
                    </div>
                </div>
            </div>
        );
    }

}
{
  "compileOnSave": true,
  "compilerOptions": {
    "outDir": "./built",
    "allowJs": true,
    "target": "es2015",
    "jsx": "preserve",
    "lib": [ "es2015", "es2016", "dom" ],
    "moduleResolution": "Node",
    "noUnusedLocals": true,
    "noUnusedParameters": true
  },
  "include": [
    "./Scripts/Components/**/*"
  ],
  "exclude": [
    "./Scripts/Interfaces/*"
  ]
}

第二个编辑:在tsconfig.jsoncompileroptions中添加“module”:“none”之后,删除了导入和导出语句。不幸的是,这消除了我以前所做的改变的影响。我在CompilerOptions中设置“moduleSolution”:“node”,以解决添加到所有文件顶部的问题。

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });

共有1个答案

贲绪
2023-03-14

我解决了将其添加到每个文件顶部的问题。

Object.defineProperty(exports, "__esModule", { value: true });

我不得不将导出移到文件的顶部。

我从这个改了

import * as React from 'react';
import { IVehicle } from "../../Interfaces/Interfaces";

export class VehiclePanel extends React.Component<IVehicle> {

    constructor(props) {
        super(props);
    }

export = VehiclePanel;
import * as React from 'react';
import { IVehicle } from "../../Interfaces/Interfaces";

class VehiclePanel extends React.Component<IVehicle> {

    constructor(props) {
        super(props);
    }

 类似资料:
  • 我在.NET相对来说是新手,我决定解决.NET核心问题,而不是学习“旧方法”。我在这里找到了一篇关于为.NET核心设置AutoMapper的详细文章,但是对于新手来说,还有更简单的演练吗?

  • 在本章中,您将学习如何在Aurelia框架中使用捆绑。 第1步 - 安装先决条件 您可以通过在command prompt运行以下命令来安装aurelia-bundler 。 C:\Users\username\Desktop\aureliaApp>npm install aurelia-bundler --save-dev 如果您没有安装gulp,可以通过运行此代码来安装它。 C:\Users

  • 但是,由于不支持webforms,我无法将控件添加到WebForm中。 是否有其他可能帮助我在ASP.NET Core Web应用程序中使用ReportViewer控件的解决方法?

  • 我们将这个库用于另一个项目,我们现在也在Xamarin中开发。目前,我们需要添加这两个库(用于ExoPlayer的my.aar和.jar)。老实说,这有点烦人,我很想把我的。Aar放进去,然后走。 所以两个问题: 有没有一种方法可以使用gradle和其他东西将ExoPlayer捆绑到我的。aar中?(我是个初学者,请仔细) 我意识到这可能不是最好的做法(依赖应该由应用程序管理,诸如此类),但实际上