美文网首页
00009.为什么插值表达式多次执行

00009.为什么插值表达式多次执行

作者: 笑着字太黑 | 来源:发表于2023-10-11 10:11 被阅读0次

【Angular】中的变化检测(ChangeDetection)_angular changedetection-CSDN博客

This is because you are using the Default change detection strategy on your component. By default all components use this strategy which means that when Angular determines a component's state is dirty it re-renders the template and cause the testnDisplay function to be called. In order to remove the component from default checking you should set the strategy to OnPush which is much more perfomant because it only re-renders the template when one of the @Input properties changes. It is still possible to have the template re-rendered but it requires the component to tell angular when to do so. Example:

import { ChangeDetectionStrategy, Component, ViewEncapsulation, OnInit, AfterViewInit, OnDestroy, HostListener } from '@angular/core';

@Component({
  /* ... */
  changeDetection: ChangeDetectionStrategy.OnPush
})
export class AppLogoComponent  {
  testnDisplay(type){
    console.log(type);
  }
}

相关文章

  • VUE.JS中的插值表达式、v-cloak、v-text、v-h

    插值表达式 {{ x }},类似这样子的就叫插值表达式 v-cloak 使用v-cloak 能够解决插值表达式闪烁...

  • Vue

    笔记 mvvm vm:就是监听页面dom元素的Vue工具 插值表达式 插值表达式:在插值表达式中可以使用简单的ja...

  • vue基础-插值表达式与常用指令

    什么是插值表达式 数据绑定最常见的形式就是使用“Mustache”语法 (双大括号) 的文本插值,就是指插值表达式...

  • Vue实例化

    1. Vue实例化 1.1 关于{{}} 插值表达式:mustache 插值表达式,表达式,赋值运算,计算,三元表...

  • Vue基本指令的使用

    v-cloak(插值表达式) 使用v-cloak能够解决插值表达式的闪烁问题 如: {{ msg }} ,在Vue...

  • Vue常用指令(完结版)

    模板语法(插值表达式) 数据绑定的最常见的形式是文本插值 {{ }} 指令 指令的作用:当表达式的值改变时,将其产...

  • vue笔记-day1

    1.MVVM概念 2.Vue基本结构代码和MVVM的对应关系 3.插值表达式   插值表达式的用法:表达式/三元表...

  • Vue.js - Vue 模板语法

    双花括号,插值表达式: 可以在挂载元素里面使用插值表达式把 data 里的 name 数据插入到 div 标签当中...

  • Vue常用系统指令

    插值表达式 数据绑定最常见的形式,其中最常见的是使用插值表达式,写法是{{}} 中写表达式 标签将会被替代为对应数...

  • vue常用

    · v-bind缩写 · 插值 文本插值(双大括号) : 属性接收参数 可使用 JavaScript 表达式 ...

网友评论

      本文标题:00009.为什么插值表达式多次执行

      本文链接:https://www.haomeiwen.com/subject/xcvgbdtx.html