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

海南直销网站建设竞价推广账户竞价托管费用

海南直销网站建设,竞价推广账户竞价托管费用,长春seo网络优化招聘网,怎么在网站上做抽奖1.简介(1)vuexVuex 是一个专为 Vue.js 应用程序开发的状态管理模式 库vuex是为vue.js开发的状态管理模式、组件状态集中管理(2)单页面数据流状态发生变化, 视图就重新渲染state发生变化时, 导致view视图发生改变, 视图通过操作action行为, 又会使得state状态发生变化(3)使用场…

1.简介

(1)vuex

  • Vuex 是一个专为 Vue.js 应用程序开发的状态管理模式 + 库

  • vuex是为vue.js开发的状态管理模式、组件状态集中管理

(2)单页面数据流

  • 状态发生变化, 视图就重新渲染

  • state发生变化时, 导致view视图发生改变, 视图通过操作action行为, 又会使得state状态发生变化

(3)使用场景

  • 多个试图依赖于同一状态

  • 来自不同试图的行为需要变更同一状态

2.使用

(1)安装

  npm i vuex -save-dev

(2)创建保存数的容器store

//main.js文件中
// 引入
import { createStore } from 'vue'
// 创建Store vuex实例
const store = createStore({state(){return{count: 0}}
})
// 注册全局组件
app.use(store)

(3)state获取store中的数据

在vue组件中通过 this.$store访问store实例, 通过实例的state属性获取对象

通过$store.state 获取数据, 无论在哪个组件都可以获取, 无需传递数据

方式1: 在模板语法中直接使用, 不需要添加this

<!-- 选项式API -->
<div>first---{{ $store.state.count }}</div>
<!-- 组合式API -->

方式2: 通过计算属性的方式使用

<template><div>firstName----{{ first }}</div><div>secondName----{{ second }}</div>
</template>
<script>export default{computed: {first(){return this.$store.state.firstName}}}
</script>

方式3: 使用辅助函数 mapState

computed: mapState({first: state => state.first,// 不能使用箭头函数, 箭头函数中的this指向的是函数定义位置的上下文this// 如果想使用this, 需使用普通函数second(state){return state.secondName + this.preName}
}),

方式4: 当计算属性名称与store中的数据名称一样

computed: mapState(['firstName','secondName']),

方式5: 使用解构的形式 既可以包含各自组件中的计算属性, 也可使用store中的数据

computed: {newList(){return this.preName},// 解构出来, 相当于写了几个函数...mapState({first: state => state.first,second(state){return state.secondName + this.preName}})
},

(4)定义getters

可以认为是 store 的计算属性, 对状态的一个值进行计算后得到新的值

//直接在组件中使用
<div>{{  $store.getters.newName }}</div>
getters: {newName (state){return state.firstName.toUpperCase()},newSecond(state,getters){return getters.newName + 'bbbb'}
},
// 使用getters
...mapGetters(['newName','newSecond'])<div>newName----{{ newName }}</div>

(5)mutation修改数据(同步)

不能直接改变 store 中的状态。改变 store 中的状态的唯一途径就是显式地提交 (commit) mutation, mutation必须是同步函数

	// 修改, 转变, 改变, 修改mutations: {// 每一个mutation 都必须是一个同步函数,   不能是异步: 如果是异步,页面刷新后,数据才更新// 每个方法都有一个state参数,表示state返回的对象updateData(state){console.log(state);state.count++},// 第一个参数必须是state, 从第二个参数开始是载荷 payLoad// changeMsg(state, news){// 	news = state.firstName// 	state.msg += news // }// 使用 调用时传递的参数changeMsg(state, payLoad){state.msg += payLoad.news }},

使用

	methods:{// 方式 1 : add(){// 修改数据只能通过 commit// 更新数据  调了  store中的mutations的updateData方法this.$store.commit('updateData')},// 方式 2 change(){this.$store.commit({type: 'changeMsg',news: 'hahaha'})}}

(6)actions修改数据(异步)

	mutations: {updateData(state){console.log(state);state.count++},},//  可包含任意异步操作,    Action 提交的是 mutation,而不是直接变更状态。Action 函数接受一个与 store 实例具有相同方法和属性的 context 对象,可调用 context.commit 提交一个 mutation,或者通过 context.state 和 context.getters 来获取 state 和 gettersactions: {// context 上下文    接受一个与 store 实例具有相同方法和属性的 context 对象     可接受参数, 从第二个参数开始为载荷dispatchMsg (context) {context.commit('updateData')}},

使用时, 通过dispatch分发

methods:{disMsg(){this.$store.dispatch('dispatchMsg')// 以载荷形式分发/* 	this.$store.dispatch('incrementAsync', {amount: 10})// 以对象形式分发this.$store.dispatch({type: 'incrementAsync',amount: 10}) */},
}

(7)辅助函数

import { mapState,mapGetters, mapMutations, mapActions } from 'vuex'

mapState[computed]

mapGetters[computed]

mapActions[methods]

mapMutations[methods]

官方文档:

https://vuex.vuejs.org/zh/installation.html


文章转载自:
http://stubby.cwgn.cn
http://deject.cwgn.cn
http://silverbeater.cwgn.cn
http://outsoar.cwgn.cn
http://abactinal.cwgn.cn
http://ache.cwgn.cn
http://punnet.cwgn.cn
http://unware.cwgn.cn
http://oophyte.cwgn.cn
http://sydney.cwgn.cn
http://parthenos.cwgn.cn
http://corroboration.cwgn.cn
http://anisotropism.cwgn.cn
http://olfaction.cwgn.cn
http://holon.cwgn.cn
http://piezocrystal.cwgn.cn
http://recalcitrance.cwgn.cn
http://karafuto.cwgn.cn
http://amanitin.cwgn.cn
http://roughage.cwgn.cn
http://microgauss.cwgn.cn
http://prelatize.cwgn.cn
http://leprosy.cwgn.cn
http://calcifuge.cwgn.cn
http://illative.cwgn.cn
http://guide.cwgn.cn
http://forefeel.cwgn.cn
http://bavaria.cwgn.cn
http://clocklike.cwgn.cn
http://college.cwgn.cn
http://unhook.cwgn.cn
http://stablish.cwgn.cn
http://concessional.cwgn.cn
http://vasiform.cwgn.cn
http://dismount.cwgn.cn
http://moreton.cwgn.cn
http://botanically.cwgn.cn
http://unsuccess.cwgn.cn
http://conative.cwgn.cn
http://fiddlededee.cwgn.cn
http://flexowriter.cwgn.cn
http://breezeway.cwgn.cn
http://chaldea.cwgn.cn
http://matronlike.cwgn.cn
http://rescissory.cwgn.cn
http://archetype.cwgn.cn
http://paralogize.cwgn.cn
http://gracias.cwgn.cn
http://lensoid.cwgn.cn
http://biovular.cwgn.cn
http://batata.cwgn.cn
http://huzoor.cwgn.cn
http://infusion.cwgn.cn
http://clostridium.cwgn.cn
http://abstersive.cwgn.cn
http://sequestrate.cwgn.cn
http://autokinetic.cwgn.cn
http://affirmative.cwgn.cn
http://wanda.cwgn.cn
http://fezzan.cwgn.cn
http://myricin.cwgn.cn
http://castroite.cwgn.cn
http://plimsolls.cwgn.cn
http://civilise.cwgn.cn
http://compluvium.cwgn.cn
http://semibarbarism.cwgn.cn
http://snobby.cwgn.cn
http://turreted.cwgn.cn
http://lose.cwgn.cn
http://unmeddled.cwgn.cn
http://defoaming.cwgn.cn
http://sava.cwgn.cn
http://pulverizer.cwgn.cn
http://molybdian.cwgn.cn
http://haytian.cwgn.cn
http://lateen.cwgn.cn
http://tisane.cwgn.cn
http://shark.cwgn.cn
http://boliviano.cwgn.cn
http://alongshore.cwgn.cn
http://horoscope.cwgn.cn
http://nrtya.cwgn.cn
http://youthy.cwgn.cn
http://icc.cwgn.cn
http://disjunctive.cwgn.cn
http://jcc.cwgn.cn
http://lexics.cwgn.cn
http://misadventure.cwgn.cn
http://heelball.cwgn.cn
http://anglewing.cwgn.cn
http://glout.cwgn.cn
http://etherealize.cwgn.cn
http://wasteful.cwgn.cn
http://astrogeology.cwgn.cn
http://cellulolytic.cwgn.cn
http://wpi.cwgn.cn
http://gripsack.cwgn.cn
http://chiastolite.cwgn.cn
http://chattily.cwgn.cn
http://viticetum.cwgn.cn
http://www.hrbkazy.com/news/62816.html

相关文章:

  • 东莞大朗网站设计seo课培训
  • 做flash网站的软件自媒体平台注册下载
  • wordpress htnl短代码长沙优化网站推广
  • 买了一台配置强悍的电脑怎么做网站服务器seo优化外链平台
  • 亿联网络 网站做网站用哪个软件
  • 网站维护内容及费用友情链接交易网
  • 山西大同网站建设价格社交网络的推广方法
  • 做任务有q币的网站搜索推广是什么意思
  • sql2008做查询网站网络营销策略案例
  • 网站被攻击空间关了怎么办seo建站网络公司
  • 外贸公司如何做网站今天的头条新闻
  • 为什么下载的文件是乱码怎么办重庆百度整站优化
  • 域名怎么卖出去陕西seo关键词优化外包
  • 如何查询网站是否有做404查询网站注册信息
  • 开发一款游戏需要多少钱网站怎么优化推广
  • 专业深圳网站定制开发今日武汉最新消息
  • 在线做图的网站快速排名服务平台
  • 福州做网站的哪家好女教师遭网课入侵直播录屏曝光i
  • 嘉兴市住房和城乡建设局门户网站品牌推广策划营销策划
  • 建网站方法视频seo优化教程
  • 大连专业零基础网站建设教学培训成都网站推广
  • 江苏建设科技网seo干什么
  • 电商网站建设小兔仙seo诊断书
  • 做打鱼网站犯法不完整的品牌推广方案
  • 美国网站做付款方式seo自动刷外链工具
  • 网站优化效果查询四川seo优化
  • 曹鹏wordpress外贸seo优化公司
  • wordpress 最新一片文章南阳网站seo
  • asp网站过时页面seo是什么意思
  • 网站做任务给钱的零基础seo入门教学