ionic-cli用于在某些文件夹中生成页面

时间:2016-10-15 12:30:48

标签: ionic-framework ionic-cli

我正在使用ionic-cli 2为我的ionic项目生成页面。我想将我的页面分别保存在不同的文件夹中。例如,我希望将LoginSignup等网页保存在名为authentication的单独文件夹中。但同时我想享受ionic generate page命令来快速设置authentication文件夹中的页面。目前ionic-cli会生成pages文件夹中的页面。如何在pages/authentication文件夹中创建它?

6 个答案:

答案 0 :(得分:2)

我知道已经有一段时间了,但这对我使用@latest ionic(3.12.0)

从应用程序的根文件夹生成“子页面”,就像生成“顶级”页面一样。然后,使用Visual Studio Code将它们拖到预期的位置。

显然你想重命名模块和类等东西。例如,对于“团队”页面的“主页”和“排名”子页面,我将这些类重命名为HomePageStandingsPageTeamHomePageTeamStandingsPage分别

或者(并且回顾推荐),使用所需的结构命名页面,例如ionic generate page team-home(您仍然需要手动移动它们)。这对于重复模式特别有用,例如,如果您还想要“主页”和“排名”子页面来表示“锦标赛”页面。

另见Can ionic2's pages support nested directory structure?

答案 1 :(得分:0)

阅读文档https://ionicframework.com/docs/cli/commands/generate 似乎可以在调用命令时直接指定要在其中生成页面或组件的文件夹。

键入public class RunTypesTest extends ShrinkWrapDeployment implements IHookable { private WebDriver driver; private static final int testPriority = 3; private static final int columnNumber = 1; private static final int dropDownNumber = 1; @Inject private DataGenerator dataGenerator; @Override public void run(IHookCallBack callBack, ITestResult testResult) { callBack.runTestMethod(testResult); System.out.println("Inside iHookable run method"); } @RunAsClient @Parameters({"browser", "logInPageUrl", "usernameField", "passwordField", "loginButton", "userMenu"}) @Test(alwaysRun = true, priority = 1, description = "This tests method is for initialising webDrive and setting test environment ONLY! This method resembles to the functionality of @BeforeClass method") private void initialiseDriverAndLogIn(@Optional("chrome") String browser, @Optional ("http://localhost:XXXX") String logInPageUrl, @Optional ("os_username") String usernameField, @Optional ("os_password") String passwordField, @Optional ("login") String loginButton, @Optional ("admin") String userMenu) { this.driver = WebDriverHelper.invokeBrowserAndLogIn(browser, logInPageUrl, usernameField, passwordField, loginButton, userMenu); } @Test(alwaysRun = true, priority = 4, description = "This test method is ONLY for deleting test data! This method resembles to the functionality of @AfterClass method") @Parameters({"portNumber" , "baseApplication"}) private void deleteTestData(@Optional ("2990") int portNumber, @Optional ("jira") String baseApplication) throws Exception { RestRequest.deleteAllRunLogs(portNumber, baseApplication); } // TODO Add arquillian script to create a total of 12 run logs which includes both (8)Bulk and (4)Scheduled user actions. @RunAsClient @Test(priority = testPriority) private void allRunTypesTest() { // The test assumes that there will be 12 following types of logs in the backend: "Deactivate users", "Change directory", "Add/remove groups", "Deactivate users", // "Add/remove groups", "Reactivate users", "Create Jira issues", "Reactivate Users - by time since last login", "Remove application groups - by the time since last log in", // "Deactivated - remove all groups", "Deactivate by - only logged in once", "Delete users") RunLogsSuiteParentBase.verifyRunLogUi(driver, dropDownNumber, "All run types", columnNumber, BackendTable.allRunTypesData()); } 会在my_dir目录中生成一个页面组件。

答案 2 :(得分:0)

我知道一开始这会很棘手。在这里,我要提到在特定目录下创建页面的步骤。

假设您的项目遵循以下目录结构:

  • src
    • 应用
      • 组件
        • 页面
        • 烟斗

要在“页面”下创建页面,请导航至“ app”目录并使用命令: 离子g页页面/测试

参考:https://ionicframework.com/docs/cli/commands/generate

答案 3 :(得分:0)

在创建单独的文件夹之前,您必须手动在应用文件夹中创建一个身份验证文件夹。

CLI>离子生成页面身份验证/登录

答案 4 :(得分:0)

只需运行

ionic generate page pages/authentication

更多信息https://ionicframework.com/docs/cli/commands/generate

答案 5 :(得分:0)

ionic g page src/app/pages/{your_pageName} 这对我有用。