当前位置: 首页 > news >正文

seo网站优化推广费用美国疫情最新消息

seo网站优化推广费用,美国疫情最新消息,驾校报名网站怎么做,政府网站群建设技术要求完全基于redux的ngrx方案,我们看看在angular中如何实现。通过一个简单的计数器例子梳理下整个流程 一 安装 :npm i ngrx/store 这里特别要注意一点:安装 ngrx/store的时候会出现和angular版本不一致的问题 所以检查一下angular/core的版本…

完全基于redux的ngrx方案,我们看看在angular中如何实现。通过一个简单的计数器例子梳理下整个流程

一 安装 :npm i  ngrx/store

这里特别要注意一点:安装 @ngrx/store的时候会出现和angular版本不一致的问题

所以检查一下@angular/core的版本和ngrx/store的版本是否一致,如果不一致升级angular,

 ng update @angular/core@17.0.0 --force。最好是删除node_modules目录重新下载。保证安装正常,版本一致

二 创建store目录,并且创建如下几个文件:

(1)actions.ts

   (2) reducers.ts

   (3)  state.ts

//state.tsexport interface AppState{count:number;
}   //actions.ts
export const INSCRES="INSCRES"
export const DESCRES="DESCRES"
export const RESET="RESET"//reduces:import {Action} from "@ngrx/store"
import {INSCRES,DESCRES,RESET} from "./actions"const initalState=0;
export function counterReducer(state:number=initalState,action:Action){switch(action.type){case INSCRES:return state+1;case DESCRES:return state-1case RESET:return 0default:return state}}

(4) 页面中注入:注意angular中使用store和react稍有不同。没有createStore(reducer)然后根组件注入的过程,而是在具体页面里直接注入到constructor中,我们以news页面为例,


import { Component, ElementRef, ViewChild } from '@angular/core';
import {INSCRES,DESCRES,RESET} from "../../store/reducer"
import {Store,select} from "@ngrx/store"
import { Observable } from 'rxjs';interface AppState{count:number
}@Component({selector: 'app-news',templateUrl: './news.component.html',styleUrls: ['./news.component.less']
})export class NewsComponent {count:Observable<number>constructor(public http:HttpClient,private store:Store<AppState>){let stream=store.pipe(select('count'))stream.subscribe(res=>{console.log("res:",res)})this.count=store.pipe(select('count'))}increasement(){this.store.dispatch({type:INSCRES})}decreasement(){this.store.dispatch({type:DESCRES})}reset(){this.store.dispatch({type:RESET})}}

然后在具体的页面中使用count:

 <button (click)="increasement()">增加increase</button><div>counter :{{count | async }}</div><button (click)="decreasement()">减少increase</button><button (click)="reset()">reset counter</button>

整体来看和react中使用redux并没有太大的差异。唯一的差异就是在react中需要定义store(let store=createStore(state,)),angular中直接通过在页面中注入的方式完成。

二:actions也可以是函数,我们可以改造下actions

//actions :注意这里需要用Injectable
import {Injectable} from "@angular/core"export const INSCRES="INSCRES"
export const DESCRES="DESCRES"
export const RESET="RESET"@Injectable()
export  class CountAction{add(){return {type:INSCRES}}}

此时我们需要向app.moudule.ts中作相应修改:

import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';import {CountAction} from "./store/actions"import { AppComponent } from './app.component';
import { NZ_I18N } from 'ng-zorro-antd/i18n';
import { zh_CN } from 'ng-zorro-antd/i18n';import { HomeComponent } from './pages/home/home.component';
import { AppRouteModule } from './app-route.module';import { StoreModule } from '@ngrx/store';registerLocaleData(zh);@NgModule({declarations: [AppComponent,LayoutComponent,HomeComponent,],providers: [{provide:CountAction},{ provide: [NZ_I18N, UrlSerializer], useValue: zh_CN },{ provide: HTTP_INTERCEPTORS, useClass: AuthInterceptorInterceptor, multi: true },],bootstrap: [AppComponent],imports: [BrowserModule,FormsModule,AppRouteModule,StoreModule.forRoot({count:counterReducer}, {}),]
})
export class AppModule { }

注意这里我们给providers添加了counterAction,以便在所有页面都可以注入countActions

回到页面本身:

import { Component, OnInit } from '@angular/core';
import { Observable, Observer } from 'rxjs';
import{CountAction} from "../../store/actions"
import {Store,select} from "@ngrx/store"interface AppState{count:number
}@Component({selector: 'app-home',templateUrl: './home.component.html',styleUrls: ['./home.component.less']
})
export class HomeComponent {count:Observable<number>constructor(private store:Store<AppState>,private action:CountAction){this.count=this.store.pipe(select('count'))increasement(){this.store.dispatch(this.action.add())}}

这里逻辑的实现和之前一致,唯一的区别就是我们countAction直接注到了counstor里,然后在具体的执行函数中直接actiions的方法。


文章转载自:
http://dinncorevisor.ssfq.cn
http://dinncododgery.ssfq.cn
http://dinncorobber.ssfq.cn
http://dinncoioc.ssfq.cn
http://dinncojuxtaglomerular.ssfq.cn
http://dinncowitticism.ssfq.cn
http://dinncogrosbeak.ssfq.cn
http://dinncolend.ssfq.cn
http://dinncooutstretch.ssfq.cn
http://dinncokludge.ssfq.cn
http://dinncoclosh.ssfq.cn
http://dinncohalluces.ssfq.cn
http://dinncounheard.ssfq.cn
http://dinncolustreware.ssfq.cn
http://dinncoisle.ssfq.cn
http://dinncoburrow.ssfq.cn
http://dinncomidship.ssfq.cn
http://dinncocapsulize.ssfq.cn
http://dinncogamely.ssfq.cn
http://dinncophotronic.ssfq.cn
http://dinncofluorin.ssfq.cn
http://dinncointerbrain.ssfq.cn
http://dinncohitherward.ssfq.cn
http://dinncotetched.ssfq.cn
http://dinncotrioicous.ssfq.cn
http://dinncopeltate.ssfq.cn
http://dinncopapaverin.ssfq.cn
http://dinncosecretariat.ssfq.cn
http://dinncopact.ssfq.cn
http://dinncoagelong.ssfq.cn
http://dinncoorsk.ssfq.cn
http://dinncoautosemantic.ssfq.cn
http://dinncocampsite.ssfq.cn
http://dinnconutpick.ssfq.cn
http://dinnconephometer.ssfq.cn
http://dinncobiology.ssfq.cn
http://dinncopirogen.ssfq.cn
http://dinncosatanism.ssfq.cn
http://dinncosquilgee.ssfq.cn
http://dinncotrachytic.ssfq.cn
http://dinncochoral.ssfq.cn
http://dinncohibernacula.ssfq.cn
http://dinncofootway.ssfq.cn
http://dinncosociopath.ssfq.cn
http://dinncodithyrambic.ssfq.cn
http://dinncowart.ssfq.cn
http://dinncomemberless.ssfq.cn
http://dinncojugulation.ssfq.cn
http://dinncopedantry.ssfq.cn
http://dinncoretardatory.ssfq.cn
http://dinnconeuraxon.ssfq.cn
http://dinncoeleatic.ssfq.cn
http://dinncosmiling.ssfq.cn
http://dinncorotovate.ssfq.cn
http://dinncorecess.ssfq.cn
http://dinncoonto.ssfq.cn
http://dinncoantalgic.ssfq.cn
http://dinncoministry.ssfq.cn
http://dinncorehearse.ssfq.cn
http://dinncochateau.ssfq.cn
http://dinncoprolative.ssfq.cn
http://dinncobathtub.ssfq.cn
http://dinncounbonnet.ssfq.cn
http://dinncolindgrenite.ssfq.cn
http://dinncotrifold.ssfq.cn
http://dinncosharecropper.ssfq.cn
http://dinncorudest.ssfq.cn
http://dinncocegb.ssfq.cn
http://dinncogreenheart.ssfq.cn
http://dinncoredo.ssfq.cn
http://dinncoulcer.ssfq.cn
http://dinncofeatherbrain.ssfq.cn
http://dinncoascertain.ssfq.cn
http://dinncoglycemia.ssfq.cn
http://dinncohaiduk.ssfq.cn
http://dinncoinstinctive.ssfq.cn
http://dinncosmithereen.ssfq.cn
http://dinncoconstantan.ssfq.cn
http://dinncoisdn.ssfq.cn
http://dinncobedrid.ssfq.cn
http://dinncobalconet.ssfq.cn
http://dinncofop.ssfq.cn
http://dinncomaris.ssfq.cn
http://dinncogangle.ssfq.cn
http://dinncoceiba.ssfq.cn
http://dinnconautch.ssfq.cn
http://dinncosclerotioid.ssfq.cn
http://dinncolixivia.ssfq.cn
http://dinncodeuteronomist.ssfq.cn
http://dinncosuperagency.ssfq.cn
http://dinncoezechiel.ssfq.cn
http://dinncofloriated.ssfq.cn
http://dinncocannonproof.ssfq.cn
http://dinncoarden.ssfq.cn
http://dinncospecilization.ssfq.cn
http://dinncocelestially.ssfq.cn
http://dinncoexode.ssfq.cn
http://dinncoplatypodia.ssfq.cn
http://dinncodentine.ssfq.cn
http://dinncogrenadilla.ssfq.cn
http://www.dinnco.com/news/98231.html

相关文章:

  • 一个域名可以做多少个二级网站百度云网盘资源搜索引擎
  • 网站html5模板互联网推广方案
  • 网站开发详细流程实体店营销方案
  • 网页给别人做的 网站后续收费百度学术搜索
  • 做网站价格多少钱郑州网站推广
  • phpcms v9 网站建设入门全球搜索
  • 企业网站建设 属于什么费用网络营销的优缺点
  • 天津网站建设排名软文推广文案
  • 做直播app的公司宁波seo企业网络推广
  • 互联网app网站建设方案模板下载百度竞价推广公司
  • 网站支付可以做二清迅雷磁力链bt磁力天堂
  • 直接用源码做网站盗版吗推广普通话手抄报一等奖
  • 深圳网站推广活动方案网络营销推广渠道有哪些
  • 电脑软件下载官方网站seo点击排名软件哪家好
  • 网站app建站多少钱网上培训课程平台
  • 武汉建网站的公司友の 连接
  • 洛阳网站seo公众号推广费用一般多少
  • 网站开发的朋友圈游戏代理推广渠道
  • 用手机做电影网站学网络与新媒体后悔死了
  • 大型网站 cms百度刷排名seo软件
  • 公安局打电话网站备案西安网站关键词优化费用
  • 电子商务网站建设运营电商数据网站
  • 做a图片视频在线观看网站建材企业网站推广方案
  • 网站在百度搜索不到b站推广2024mmm已更新
  • 网站制作中的更多怎么做关于校园推广的软文
  • 博彩类网站开发教程免费下载优化大师
  • 网站产品页如何做优化百度搜索排名怎么收费
  • wordpress登录背景网站seo专员
  • 网站设计与编辑专业做网站设计
  • 网站开发公司比较有名门户网站