zoukankan      html  css  js  c++  java
  • Angular(2)

    在angular中使用双向数据绑定需要引入相关的模块,并且在组件中配置好

    angular也有和vuex类似的服务,名为services,通过ng g s servicename创建服务

    angular可以用自带的ViewChild操作DOM,先引入ViewChild:

                                ①.给模板中的dom起一个名字,<div #myBox></div>

                                ②.在业务逻辑里面引入ViewChild , import { Component, OnInit ,ViewChild} from '@angular/core';

                                ③.写在类里面 @ViewChild('myBox')myBox:any;

                                ④.ngAfterViewInit生命周期函数里面获取dom,使用方法:this.myBox.nativeElement

  • 相关阅读:
    crmfuxi
    段子
    wsfenxiang
    生成器、列表推导式
    闭包、迭代器、递归
    函数的参数及返回值
    嵌套、作用域、命名空间
    定义、函数的调用
    测试样式
    进制转换
  • 原文地址:https://www.cnblogs.com/ttaoai/p/13343315.html
Copyright © 2011-2022 走看看