Ionic创建Component
发布时间:2020-12-17 08:14:43 所属栏目:安全 来源:网络整理
导读:各位看官,若您在阅读一下内容的时候,若存在与此主题相关但未涉及的内容,请留言,将会及时对该内容进行维护,互相指点,提升学习,提高技能邮箱地址 新建项目 命令说明: ionic start `project-name` 参数说明: 参数 说明 ionic ionic cli 工具 start ionic 新建
各位看官,若您在阅读一下内容的时候,若存在与此主题相关但未涉及的内容,请留言,将会及时对该内容进行维护,互相指点,提升学习,提高技能邮箱地址 新建项目命令说明: ionic start `project-name` 参数说明:
示例代码: ionic start helloworld 可选择对应的初始化项目模板 新建组件ionic g component `component-name` 参数说明:
示例代码: ionic g component x-header 生成文件: -. components 文件内容: components.module.ts import { NgModule } from '@angular/core'; import { CHeaderComponent } from './c-header/c-header'; import { CArticleComponent } from './c-article/c-article'; @NgModule({ declarations: [ CHeaderComponent,],imports: [],exports: [ CHeaderComponent,] }) export class ComponentsModule {} x-header.html <div class="c-header"> {{text}} </div> x-header.scss c-header { } x-header.ts import { Component } from '@angular/core'; /** * Generated class for the CHeaderComponent component. * * See https://angular.io/api/core/Component for more info on Angular * Components. */ @Component({ selector: 'c-header',templateUrl: 'c-header.html' }) export class CHeaderComponent { text: string; constructor() { console.log('Hello CHeaderComponent Component'); this.text = 'Hello World'; } } 特别注意:
特别注意: 请勿在自定义组件的 (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |