简体   繁体   English

无法在Visual Studio Code中创建角度组件

[英]Cannot create angular component in Visual Studio Code

I am trying to create an angular component in visual studio code. 我正在尝试在Visual Studio代码中创建一个角度组件。 By default, my angular components are in ClientApp. 默认情况下,我的角度组件位于ClientApp中。 I have some default components in ClientApp. 我在ClientApp中有一些默认组件。 When I tried to add a new angular component in the components folder in ClientApp I get an error. 当我尝试在ClientApp的components文件夹中添加新的角度组件时,出现错误。

When I enter "ng g component vehicle-form" I have an error. 输入“ ng g component vehicle-form”时,出现错误。 It says " Invalid path: "vehicle-form" cannot be above the "ClientApp\\app" directory." 它说:“无效的路径:“车辆形式”不能在“ ClientApp \\ app”目录上方。” However, my angular components are in the app folder located within the app folder of Client App. 但是,我的角度分量位于Client App的app文件夹内的app文件夹中。

PS C:\\Users\\Sushi\\vega> cd ClientApp PS C:\\ Users \\ Sushi \\ vega> cd ClientApp
PS C:\\Users\\Sushi\\vega\\ClientApp> cd app PS C:\\ Users \\ Sushi \\ vega \\ ClientApp> cd应用程序
PS C:\\Users\\Sushi\\vega\\ClientApp\\app> cd components PS C:\\ Users \\ Sushi \\ vega \\ ClientApp \\ app> cd组件
PS C:\\Users\\Sushi\\vega\\ClientApp\\app\\components> ng g component vehicle-form PS C:\\ Users \\ Sushi \\ vega \\ ClientApp \\ app \\ components> ng g组件车辆形式
Invalid path: "vehicle-form" cannot be above the "ClientApp\\app" directory 无效的路径:“车辆形式”不能位于“ ClientApp \\ app”目录上方

My .angular-cli.json configuration is as listed below. 我的.angular-cli.json配置如下所示。

"apps": [
        {
          "root": "ClientApp",
          "outDir": "dist",
          "assets": [
            "assets",
            "favicon.ico"

If you want to create a component from angular cli then just run the command 如果要从angular cli创建组件,则只需运行以下命令

  ng g component vehicle-form

From your root directory ie 从您的根目录即

 PS C:\Users\Sushi\vega\ClientApp> ng g component vehicle-form

try to change 尝试改变

 "apps": [
        {
          "root": "src",
          "outDir": "dist",
          "assets": [
            "assets",
            "favicon.ico"

then ng gc vehicle-form 然后ng gc车辆形式

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM