4.8k 字 4 分钟

# Angular 中的生命周期函数 官方文档:https://angular.cn/guide/lifecycle-hooks 生命周期函数通俗的讲就是组件创建、组件更新、组件销毁的时候会触发的一系列的方法。 当 Angular 使用构造函数新建一个组件或指令后,就会按下面的顺序在特定时刻调用这些生命周期钩子方法。 注意 constructor 不是生命周期函数,构造函数中使用了简单的值对局部变量进行初始化外,什么都不应该做。 钩子 用途及时机 ngOnChanges() 当 Angular(重新)设置数据绑定输入属性时响应。该方法接受当前和上一属性值的 SimpleChanges...
1.2k 字 1 分钟

# 需求 ES 里有两个 fileds 数据,其实性质上是一致的,都是统计 cluster,但是名字不同,一个叫 cluster,一个叫 cluster_name,在尝试做 visualize 时因为 terms 时仅能够对其中一个 filed 生效,会导致另一列数据无法统计,会丢掉 # 探索 # 尝试 ES 官方提供的 3 种方法 ES 官方给了三种方法,参考地址 # 方法一:Script 在 dsl 中写入脚本,在 devtool 测试脚本时报错,说没有 runtime_mappings 这个 type,网上查询后原来我们 es 版本低不支持 runtime_mappings,并且...
5.3k 字 5 分钟

父组件不仅可以给子组件传递简单的数据,还可以把自己的方法以及整个父组件传给子组件 # 创建项目与组件 D:\angular>ng new angulardemo07D:\angular>cd angulardemo07D:\angular\angulardemo07>ng g component components/homeD:\angular\angulardemo07>ng g component components/newsD:\angular\angulardemo07>ng g component...
9.7k 字 9 分钟

# 背景 Vue 版本: 2.6.10 vue-element-admin 版本:4.2.1 日历组件: vue-simple-calendar@5.0.1 日历组件 Github 地址: https://github.com/richardtallent/vue-simple-calendar 日历组件在线 Demo 地址: https://tallent.us/vue-simple-calendar/ 需求: 用户希望通过右键 calendar 组件里某一天的某一项,弹出一个菜单,在菜单里面修改这一项 # 效果 # 代码 下面代码直接引入到 router 里的 index.js...
4.8k 字 4 分钟

# 涉及命令 PS D:\angular\angulardemo06> ng new angulardemo06 # 创建项目PS D:\angular\angulardemo06> ng g component components/home # 创建 home 组件PS D:\angular\angulardemo06> ng g component components/news # 创建新闻组件PS D:\angular\angulardemo06> ng g component components/header # 创建 header 头部组件PS...
6k 字 5 分钟

# 相关命令 PS D:\angular\angulardemo05> ng --help # 获取帮助PS D:\angular\angulardemo05> ng g --help # 获取帮助PS D:\angular\angulardemo05> ng g service services/storage # 创建服务PS D:\angular\angulardemo05> ng serve --open # 启动项目# app.module.ts import { NgModule } from...
2.5k 字 2 分钟

# 创建组件 PS D:\angular\angulardemo05> ng g component components/todolist# app.module.ts 引入 form module import { NgModule } from '@angular/core';import { BrowserModule } from '@angular/platform-browser';import { FormsModule } from...
1.7k 字 2 分钟

# 创建组件 PS D:\angular\angulardemo05> ng g component components/search# app.module.ts 引入 form module import { NgModule } from '@angular/core';import { BrowserModule } from '@angular/platform-browser';import { FormsModule } from...
4.1k 字 4 分钟

# Angular 组件基础使用 ng g component components/home , app.module.ts 文件会自动添加 HomeComponent 组件 app.component.html 文件添加标签 <app-home></app-home> app.module.ts 手动添加 FormsModule 组件,测试表单数据双向绑定,即 MVVM,注意 imports home.component.scss 的简单样式不再罗列,可以自行补入 home.component.ts 代码如下import...