久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

Visual Studio 2017 中的反應項目

React project in Visual Studio 2017(Visual Studio 2017 中的反應項目)
本文介紹了Visual Studio 2017 中的反應項目的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

限時送ChatGPT賬號..

我想在 Visual Studio 2017 中與我的 .NET 應用程序一起開發一個 React 應用程序(在同一個解決方案中).

我正在使用 TypeScript,所以我想要一個可以自定義構建的項目類型(我想對項目進行 webpack 等,所以標準的 Visual Studio TypeScript 構建是不夠的).

我已經安裝了 node.js 開發工具,但它們只允許我創建 node.js 特定項目(啟動時運行 node.js 實例)并且不要讓我自定義構建過程.

哪種項目類型最適合這個?

解決方案

我最近做了這個,建議如下:

  1. 在 Visual Studio 2017 中創建一個空白"解決方案項目.
  2. 像往常一樣在 Visual Studio 中添加/創建 .NET 項目.
  3. 現在創建您的 React 項目.我使用 Facebook 的 create-react-app 來實際生成我的 React 項目.這有很多非常好的內置功能,例如 Webpack、Jest(用于測試)、yarn(用于包管理)等.但是,這些細節對您是隱藏的",因此生成的項目看起來要簡單得多.如果您確實需要對構建/測試過程進行更多控制,您可以運行 create-react-appject 命令.請注意,這是一個單向"操作,因為您無法將文件放回 create-react-app.您需要安裝 node 和 紗線,如果不明顯的話.
  4. 既然你也想使用 TypeScript,你應該使用 react-scripts-ts 腳本如下:

    create-react-app my-app --scripts-version=react-scripts-ts

    微軟在這里有很好的了解..p>

  5. 棘手的部分是將生成的 React 項目導入 Visual Studio.我通過從隨 Visual Studio 一起安裝的Visual Studio 安裝程序"安裝Node.js 開發"模塊來做到這一點.不幸的是,微軟似乎已經刪除了空白或空的 TypeScript 項目模板(請參閱此處).

  6. 安裝 Node.js 工具后,您可以在解決方案中創建基于節點的項目.在 File -> New -> Project... -> Templates -> Other Languages -> TypeScript 左側菜單導航下有幾個可供選擇.我選擇了空白 Node.js Web 應用程序".

  7. 之后,您需要將 create-react-app 創建的 React 項目文件復制到您的 Visual Studio 項目中.我發現在 Visual Studio 中創建目錄更容易,因此將它們添加到項目文件中,然后將文件復制到生成的文件夾中,最后將它們添加到 Visual Studio 中的項目文件夾中.

  8. 此時,您可以運行 create-react-app 添加的 package.json 文件中的腳本.我更喜歡在命令行中運行它們,但您也可以在 Visual Studio 中運行它們,也可以使用 Mads Kristensen 的Task Runner Explorer".

I want to develop a React application in Visual Studio 2017 alongside my .NET application (in the same solution).

I am using TypeScript, so I want a project type where I can customise the build (I want to webpack the project, etc, so the standard Visual Studio TypeScript build is not enough).

I have installed the node.js developer tools but they only allow me to create node.js specific projects (which run a node.js instance when started) and do not let me customise the build process.

Which project type will be best for this?

解決方案

I recently did this and would recommend the following:

  1. Create a "Blank" solution project in Visual Studio 2017.
  2. Add/create your .NET project as you would normally in Visual Studio.
  3. Now create your React project. I used the create-react-app from Facebook to actually generate my React project. This has a lot of really good built in features such as Webpack, Jest (for testing), yarn (for package management), etc. However, these details are "hidden" from you so the generated project looks much simpler. If you do need more control over the build/testing process you can run the create-react-app eject command. Be advised that this is a "one-way" operation as you can't put the files back in to create-react-app. You will need to install node and yarn separately, if that wasn't obvious.
  4. Since you also want to use TypeScript you should use the react-scripts-ts script like so:

    create-react-app my-app --scripts-version=react-scripts-ts

    Microsoft has a good walk through here.

  5. The tricky part is getting the generated React project into Visual Studio. I did this by installing the "Node.js development" module from the "Visual Studio Installer" that gets installed with Visual Studio. Unfortunately, Microsoft seems to have removed the blank or empty TypeScript project template (see here).

  6. Once the Node.js tools are installed you can create a node based project in your solution. There are several to choose from under the File -> New -> Project... -> Templates -> Other Languages -> TypeScript left menu navigation. I chose "Blank Node.js Web Application".

  7. After that you will need to copy over the React project files created by create-react-app into your Visual Studio project. I find it easier to create the directories in Visual Studio so they are added to the project file, then copy the files the generated folders, and finally add them to the project folder in Visual Studio.

  8. At this point you can run the scripts in the package.json file that were added by create-react-app. I prefer to run these at the command line, but you can run them in Visual Studio as well using the "Task Runner Explorer" by Mads Kristensen.

這篇關于Visual Studio 2017 中的反應項目的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

How can I get my jasmine tests fixtures to load before the javascript considers the document to be quot;readyquot;?(在 javascript 認為文檔“準備好之前,如何讓我的 jasmine 測試裝置加載?) - IT屋-程序員軟件開發技術
What do jasmine runs and waitsFor actually do?(jasmine 運行和等待實際上是做什么的?)
How to provide mock files to change event of lt;input type=#39;file#39;gt; for unit testing(如何提供模擬文件來更改 lt;input type=filegt; 的事件用于單元測試)
How to unit test a chained method using Jasmine(如何使用 Jasmine 對鏈式方法進行單元測試)
How do I inject $rootScope into an AngularJS unit test?(如何將 $rootScope 注入 AngularJS 單元測試?)
Jasmine - How to spy on a function call within a function?(Jasmine - 如何監視函數中的函數調用?)
主站蜘蛛池模板: 国产精品揄拍一区二区久久国内亚洲精 | 日韩在线小视频 | 欧美成人精品一区二区男人看 | 男女午夜激情视频 | 黄色网毛片 | 最新av在线播放 | 亚洲精品一区二三区不卡 | 精品欧美激情精品一区 | 色综合久久伊人 | 美女久久视频 | 色悠悠久| 亚洲一区二区电影网 | 天天躁日日躁狠狠的躁天龙影院 | 免费一级欧美在线观看视频 | 美女视频黄的免费 | 日韩毛片免费看 | 性欧美精品一区二区三区在线播放 | 亚洲精品国产a久久久久久 中文字幕一区二区三区四区五区 | 国产精品不卡 | www日本在线观看 | 中文字幕在线不卡播放 | 久久精品91久久久久久再现 | caoporon| 久久久国产一区二区三区 | 91免费视频观看 | av在线免费网站 | 久久极品 | 黄色毛片在线播放 | 国产精品1区 | 视频在线一区二区 | 日本午夜免费福利视频 | 一区二区三区在线免费观看 | 国产精品久久久久久久久久久免费看 | 国产一区二区三区 | 一区二区伦理电影 | 精品久久久久久久久久 | 黄色一级大片在线免费看产 | 在线观看你懂的网站 | 日韩视频免费看 | 久久免费香蕉视频 | 日本不卡一区 |