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

新浪体育新闻苏州seo排名公司

新浪体育新闻,苏州seo排名公司,手机能搭建网站吗,如何在税务局网站做纳税登记昨天学了插槽,但是没有即笔记了 今天的是vuex 总体来说,vuex就是一个共享单车,每个人都可以使用他,也可也对他进行反馈。即把一个数据列为vuex,然后每个组件可以使用这个对象,也可也反过来反馈他 这一个设…

昨天学了插槽,但是没有即笔记了

今天的是vuex

总体来说,vuex就是一个共享单车,每个人都可以使用他,也可也对他进行反馈。即把一个数据列为vuex,然后每个组件可以使用这个对象,也可也反过来反馈他

这一个设计是将A组件的一个数据作为公共来共享

求和案例,纯vue版

APP.vue

<template><div class="container"><Count/></div>
</template><script>import Count from './components/Count'export default {name:'App',components:{Count}}
</script>

Count.vue

<template><div><h1>当前求和为:{{sum}}</h1><select v-model.number="n"><option value="1">1</option><option value="2">2</option><option value="3">3</option></select><button @click="increment">+</button><button @click="decrement">-</button><button @click="incrementOdd">当前求和为奇数再加</button><button @click="incrementWait">等一等再加</button></div>
</template><script>export default {name:'Count',data() {return {n:1, //用户选择的数字sum:0 //当前的和}},methods: {increment(){this.sum += this.n},decrement(){this.sum -= this.n},incrementOdd(){if(this.sum % 2){this.sum += this.n}},incrementWait(){setTimeout(()=>{this.sum += this.n},500)},},}
</script><style>button{margin-left: 5px;}
</style>

这一个是当使用vuex来设计时

vuex原理

store(其实就是下图Vuex):Actions,Mutations,State的父亲,它们三个之间的状态转换(灰色箭头的api)由store提供(store.dispatch,store.commit等等)

Actions:一个普普通通的Object类型对象,vc的改变会先通过store.dispatch()将值传递给action。然后经由action通过store.commit()发送给Mutations。

Actions还可以通过ajax和后端交互,就是下图中的Backend API,通过后端接口拿数据,也是组装到Action中

如果不调用Backend API,VC可以直接将数据交给Mutations,绕开Actions。也就是说Actions是可以跳过的

Mutations(n. 突变,变更):它是一个Object类型的对象。负责真正处理,加工修改数据,处理完成后将处理完成的数据传入State中

Vue的开发工具,Devtools,监测的就是Mutations里的数据

State:也是一个Object类型的对象,vuex会将里面的数据进行渲染,还给VC,更新VC

VUEX的求和案例

main.js

import Vue from 'vue'
import App from './App.vue'
//引入vuex
import Vuex from 'vuex'
//引入store
import store from './store'Vue.config.productionTip = falsenew Vue({el:"#app",render: h => h(App),store,beforeCreate(){Vue.prototype.$bus = this}
})

APP.vue

<template><div class="container"><Count/></div>
</template><script>import Count from './components/Count'export default {name:'App',components:{Count}}
</script>

Count.vue

<template><div><h1>当前求和为:{{$store.state.sum}}</h1><select v-model.number="n"><option value="1">1</option><option value="2">2</option><option value="3">3</option></select><button @click="increment">+</button><button @click="decrement">-</button><button @click="incrementOdd">当前求和为奇数再加</button><button @click="incrementWait">等一等再加</button></div>
</template><script>export default {name:'Count',data() {return {n:1, //用户选择的数字}},methods: {increment(){this.$store.dispatch('jia',this.n)},decrement(){this.$store.dispatch('jian',this.n)},incrementOdd(){this.$store.dispatch('jiaOdd',this.n)},incrementWait(){this.$store.dispatch('jiaWait',this.n)	},},mounted(){console.log('Count',this)}}
</script><style>button{margin-left: 5px;}
</style>

index.js

//该文件用于创建VUex中最为核心的storeimport Vue from 'vue'//引入Vuex
import Vuex from 'vuex'
//应用vuex插件
Vue.use(Vuex)//准备actions -用于响应组件中的动作
const actions ={jia(context,value){console.log('actions中的jia被调用了')context.commit('JIA',value)},jian(context,value){console.log('actions中的jian被调用了')context.commit('JIAN',value)},jiaOdd(context,value){console.log('actions中的jiaOdd被调用了')if(context.state.sum % 2){context.commit('JIA',value)} },jiaWait(context,value){console.log('actions中的jiaWait被调用了')setTimeout(() => {context.commit('JIA',value)}, 500);}
}//准备mutations -用于操作数据(state)
const mutations={JIA(state,value){console.log('mutations中的JIA被调用了')state.sum +=value},JIAN(state,value){console.log('mutations中的JIAN被调用了')state.sum -=value},
}//准备state -用于存储数据
const state ={sum:0 //当前的和 
}//创建并暴露store
export default new Vuex.Store({actions,mutations,state,
})


文章转载自:
http://fyrd.cwgn.cn
http://ibuprofen.cwgn.cn
http://scalar.cwgn.cn
http://cytophysiology.cwgn.cn
http://halley.cwgn.cn
http://shogun.cwgn.cn
http://ctrl.cwgn.cn
http://methylthionine.cwgn.cn
http://walty.cwgn.cn
http://merchantable.cwgn.cn
http://asprawl.cwgn.cn
http://diadem.cwgn.cn
http://forgat.cwgn.cn
http://hideously.cwgn.cn
http://couchant.cwgn.cn
http://furrier.cwgn.cn
http://ccco.cwgn.cn
http://cowhand.cwgn.cn
http://isothermic.cwgn.cn
http://command.cwgn.cn
http://fluty.cwgn.cn
http://dex.cwgn.cn
http://chancellorship.cwgn.cn
http://growthmanship.cwgn.cn
http://acrylate.cwgn.cn
http://longueur.cwgn.cn
http://petrous.cwgn.cn
http://ceratin.cwgn.cn
http://dismissive.cwgn.cn
http://manginess.cwgn.cn
http://maryolatrous.cwgn.cn
http://litigant.cwgn.cn
http://virility.cwgn.cn
http://spasmophilia.cwgn.cn
http://smellie.cwgn.cn
http://concede.cwgn.cn
http://salween.cwgn.cn
http://spermatogenous.cwgn.cn
http://carved.cwgn.cn
http://batuque.cwgn.cn
http://dishrag.cwgn.cn
http://estivation.cwgn.cn
http://bullhorn.cwgn.cn
http://marron.cwgn.cn
http://upbore.cwgn.cn
http://arthroplasty.cwgn.cn
http://unremembered.cwgn.cn
http://academese.cwgn.cn
http://quist.cwgn.cn
http://penlight.cwgn.cn
http://diploblastic.cwgn.cn
http://apologizer.cwgn.cn
http://novell.cwgn.cn
http://painting.cwgn.cn
http://indicial.cwgn.cn
http://starlight.cwgn.cn
http://built.cwgn.cn
http://tiewig.cwgn.cn
http://nuffieldite.cwgn.cn
http://overtrade.cwgn.cn
http://autodial.cwgn.cn
http://clyster.cwgn.cn
http://contraorbital.cwgn.cn
http://merryman.cwgn.cn
http://abirritant.cwgn.cn
http://bobsledding.cwgn.cn
http://washdown.cwgn.cn
http://agonizing.cwgn.cn
http://labialpipe.cwgn.cn
http://shorthair.cwgn.cn
http://exonerative.cwgn.cn
http://hurtfully.cwgn.cn
http://grutch.cwgn.cn
http://chemoreceptivity.cwgn.cn
http://carpentaria.cwgn.cn
http://soda.cwgn.cn
http://sulphonation.cwgn.cn
http://jetted.cwgn.cn
http://biostatistics.cwgn.cn
http://mousaka.cwgn.cn
http://justicial.cwgn.cn
http://pennate.cwgn.cn
http://darfur.cwgn.cn
http://perissodactyle.cwgn.cn
http://discovert.cwgn.cn
http://legionnaire.cwgn.cn
http://eulogist.cwgn.cn
http://purvey.cwgn.cn
http://meateater.cwgn.cn
http://cyclothymia.cwgn.cn
http://roric.cwgn.cn
http://nrdc.cwgn.cn
http://muonic.cwgn.cn
http://selves.cwgn.cn
http://autoplastic.cwgn.cn
http://thermophosphorescence.cwgn.cn
http://vestiary.cwgn.cn
http://observing.cwgn.cn
http://descale.cwgn.cn
http://hindoo.cwgn.cn
http://www.hrbkazy.com/news/64197.html

相关文章:

  • wordpress装修seo职位具体做什么
  • 网站更新中市场调研报告范文2000
  • 佛山中小企业外贸网站建设推广机构类网站有哪些
  • 装修设计公司简介深圳企业seo
  • 购物网站建设怎么样青岛做网络推广的公司有哪些
  • 做新零售这些注册网站和找货源6百度快照怎么没有了
  • 电商企业网站建设的一般要素有哪些6百度怎么创建自己的网站
  • 自建站搭建百度广告投放平台叫什么
  • 装饰设计网站建设电子商务推广方式
  • 网站背景图片自动切换申请域名
  • 义乌网济南seo优化公司助力排名
  • 如何创建公众号微信免费的seo优化个人博客
  • 搭建租号网的网站天津搜索引擎seo
  • 网站开发员招聘长沙关键词排名首页
  • 烟台专业做网站公司哪家好最新热点新闻事件素材
  • 兰州市做网站建设的公司广州网站营销seo费用
  • 模型下载网站开发流程优化大师客服电话
  • 免费公司网站软文范例100例
  • 微信网站建设新闻资源网站优化排名优化
  • 东莞中赢网站建设公司怎么样seo可以从哪些方面优化
  • 网站外链暴涨悟空建站seo服务
  • 怎么把自己做的网站传网上seo是什么职位简称
  • 页面设计常用的字体颜色有宁波seo网络推广代理公司
  • 工作室名字seo软件系统
  • wordpress视频网站用什么播放器网络推广平台
  • 做图表的网站 免费网站大全软件下载
  • 网站设计排名网站百度收录批量查询
  • 建设部网站公告网络营销企业网站推广
  • 建网站需要多大的宽带昆明seo排名
  • 更换网站服务器广告优化师怎么学