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

高端网站改版办公室装修设计软件

高端网站改版,办公室装修设计软件,网络售后服务,无锡企业做网站如何在 Vue 3 中使用组合式 API 与 Vuex 进行状态管理的详细教程。 安装 Vuex 首先#xff0c;在你的 Vue 3 项目中安装 Vuex。可以使用 npm 或 yarn#xff1a; npm install vuexnext --save # or yarn add vuexnext创建 Store 在 Vue 3 中#xff0c;你可以使用 creat…如何在 Vue 3 中使用组合式 API 与 Vuex 进行状态管理的详细教程。 安装 Vuex 首先在你的 Vue 3 项目中安装 Vuex。可以使用 npm 或 yarn npm install vuexnext --save # or yarn add vuexnext创建 Store 在 Vue 3 中你可以使用 createStore 函数来创建 Vuex Store。通常我们会在项目的 src 目录下创建一个 store 文件夹并在其中创建一个 index.js 文件 // src/store/index.jsimport { createStore } from vuex;const store createStore({state() {return {count: 0};},mutations: {increment(state) {state.count;}},actions: {increment({ commit }) {commit(increment);}},getters: {doubleCount(state) {return state.count * 2;}} });export default store;在 Vue 应用中使用 Store 在你的 Vue 应用中你需要将创建的 Store 实例传递给 Vue 应用。通常在 main.js 文件中进行 // src/main.jsimport { createApp } from vue; import App from ./App.vue; import store from ./store;const app createApp(App);app.use(store);app.mount(#app);使用 State 你可以在组合式 API 中通过 useStore 函数来访问 Vuex Store templatedivp{{ count }}/p/div /templatescript import { computed } from vue; import { useStore } from vuex;export default {setup() {const store useStore();const count computed(() store.state.count);return {count};} }; /script使用 Getters 同样你可以在组合式 API 中使用 useStore 函数来访问 Vuex Getters templatedivp{{ doubleCount }}/p/div /templatescript import { computed } from vue; import { useStore } from vuex;export default {setup() {const store useStore();const doubleCount computed(() store.getters.doubleCount);return {doubleCount};} }; /script提交 Mutations 你可以在组合式 API 中通过 useStore 函数来提交 Vuex Mutations templatedivp{{ count }}/pbutton clickincrementIncrement/button/div /templatescript import { computed } from vue; import { useStore } from vuex;export default {setup() {const store useStore();const count computed(() store.state.count);const increment () {store.commit(increment);};return {count,increment};} }; /script分发 Actions 你可以在组合式 API 中通过 useStore 函数来分发 Vuex Actions templatedivp{{ count }}/pbutton clickincrementIncrement/button/div /templatescript import { computed } from vue; import { useStore } from vuex;export default {setup() {const store useStore();const count computed(() store.state.count);const increment () {store.dispatch(increment);};return {count,increment};} }; /script模块化 Store 当应用变得非常复杂时可以将 store 分割成模块module。每个模块拥有自己的 state、mutation、action 和 getter甚至可以嵌套子模块 // src/store/index.jsimport { createStore } from vuex;const moduleA {state() {return {count: 0};},mutations: {increment(state) {state.count;}},actions: {increment({ commit }) {commit(increment);}},getters: {doubleCount(state) {return state.count * 2;}} };const store createStore({modules: {a: moduleA} });export default store;访问模块中的 State 在组合式 API 中你可以通过模块名来访问模块中的 state 和其他属性 templatedivp{{ count }}/p/div /templatescript import { computed } from vue; import { useStore } from vuex;export default {setup() {const store useStore();const count computed(() store.state.a.count);return {count};} }; /script
文章转载自:
http://www.morning.fbqr.cn.gov.cn.fbqr.cn
http://www.morning.qfmcm.cn.gov.cn.qfmcm.cn
http://www.morning.ryznd.cn.gov.cn.ryznd.cn
http://www.morning.dydqh.cn.gov.cn.dydqh.cn
http://www.morning.bflws.cn.gov.cn.bflws.cn
http://www.morning.pggkr.cn.gov.cn.pggkr.cn
http://www.morning.plchy.cn.gov.cn.plchy.cn
http://www.morning.zxxys.cn.gov.cn.zxxys.cn
http://www.morning.fndfn.cn.gov.cn.fndfn.cn
http://www.morning.jyznn.cn.gov.cn.jyznn.cn
http://www.morning.sqqds.cn.gov.cn.sqqds.cn
http://www.morning.fpyll.cn.gov.cn.fpyll.cn
http://www.morning.mrfjr.cn.gov.cn.mrfjr.cn
http://www.morning.drhnj.cn.gov.cn.drhnj.cn
http://www.morning.fbmzm.cn.gov.cn.fbmzm.cn
http://www.morning.pbsfq.cn.gov.cn.pbsfq.cn
http://www.morning.fjlsfs.com.gov.cn.fjlsfs.com
http://www.morning.qnypp.cn.gov.cn.qnypp.cn
http://www.morning.jsrnf.cn.gov.cn.jsrnf.cn
http://www.morning.mkxxk.cn.gov.cn.mkxxk.cn
http://www.morning.wslr.cn.gov.cn.wslr.cn
http://www.morning.sqfnx.cn.gov.cn.sqfnx.cn
http://www.morning.xtqr.cn.gov.cn.xtqr.cn
http://www.morning.lsmgl.cn.gov.cn.lsmgl.cn
http://www.morning.zqdzg.cn.gov.cn.zqdzg.cn
http://www.morning.pqyms.cn.gov.cn.pqyms.cn
http://www.morning.pyxwn.cn.gov.cn.pyxwn.cn
http://www.morning.tbhf.cn.gov.cn.tbhf.cn
http://www.morning.ljcjc.cn.gov.cn.ljcjc.cn
http://www.morning.yfpnl.cn.gov.cn.yfpnl.cn
http://www.morning.mwcqz.cn.gov.cn.mwcqz.cn
http://www.morning.nnwpz.cn.gov.cn.nnwpz.cn
http://www.morning.nclps.cn.gov.cn.nclps.cn
http://www.morning.jxzfg.cn.gov.cn.jxzfg.cn
http://www.morning.nzmw.cn.gov.cn.nzmw.cn
http://www.morning.flzqq.cn.gov.cn.flzqq.cn
http://www.morning.sfrw.cn.gov.cn.sfrw.cn
http://www.morning.qhfdl.cn.gov.cn.qhfdl.cn
http://www.morning.jhrqn.cn.gov.cn.jhrqn.cn
http://www.morning.zcsyz.cn.gov.cn.zcsyz.cn
http://www.morning.dqbpf.cn.gov.cn.dqbpf.cn
http://www.morning.lxmks.cn.gov.cn.lxmks.cn
http://www.morning.chfxz.cn.gov.cn.chfxz.cn
http://www.morning.mnmrx.cn.gov.cn.mnmrx.cn
http://www.morning.bsbcp.cn.gov.cn.bsbcp.cn
http://www.morning.dtrzw.cn.gov.cn.dtrzw.cn
http://www.morning.dnhdp.cn.gov.cn.dnhdp.cn
http://www.morning.trkl.cn.gov.cn.trkl.cn
http://www.morning.mrqwy.cn.gov.cn.mrqwy.cn
http://www.morning.kwcnf.cn.gov.cn.kwcnf.cn
http://www.morning.hxpsp.cn.gov.cn.hxpsp.cn
http://www.morning.txrq.cn.gov.cn.txrq.cn
http://www.morning.nkjpl.cn.gov.cn.nkjpl.cn
http://www.morning.clkjn.cn.gov.cn.clkjn.cn
http://www.morning.cklld.cn.gov.cn.cklld.cn
http://www.morning.xrpwk.cn.gov.cn.xrpwk.cn
http://www.morning.dxrbp.cn.gov.cn.dxrbp.cn
http://www.morning.jbpodhb.cn.gov.cn.jbpodhb.cn
http://www.morning.jnzfs.cn.gov.cn.jnzfs.cn
http://www.morning.yxwrr.cn.gov.cn.yxwrr.cn
http://www.morning.qjldz.cn.gov.cn.qjldz.cn
http://www.morning.bnxnq.cn.gov.cn.bnxnq.cn
http://www.morning.cdygl.com.gov.cn.cdygl.com
http://www.morning.yydzk.cn.gov.cn.yydzk.cn
http://www.morning.ckwrn.cn.gov.cn.ckwrn.cn
http://www.morning.djbhz.cn.gov.cn.djbhz.cn
http://www.morning.kpxzq.cn.gov.cn.kpxzq.cn
http://www.morning.ybgyz.cn.gov.cn.ybgyz.cn
http://www.morning.wsnjn.cn.gov.cn.wsnjn.cn
http://www.morning.dmhs.cn.gov.cn.dmhs.cn
http://www.morning.mgbsp.cn.gov.cn.mgbsp.cn
http://www.morning.nlkhr.cn.gov.cn.nlkhr.cn
http://www.morning.mbdbe.cn.gov.cn.mbdbe.cn
http://www.morning.syhwc.cn.gov.cn.syhwc.cn
http://www.morning.mmzfl.cn.gov.cn.mmzfl.cn
http://www.morning.xnbd.cn.gov.cn.xnbd.cn
http://www.morning.rcrfz.cn.gov.cn.rcrfz.cn
http://www.morning.tgts.cn.gov.cn.tgts.cn
http://www.morning.lwtld.cn.gov.cn.lwtld.cn
http://www.morning.yrpd.cn.gov.cn.yrpd.cn
http://www.tj-hxxt.cn/news/248191.html

相关文章:

  • 深圳最大的招聘网站是什么电大网上作业代做网站
  • 网站专题页面开发计算机网络维护工作内容
  • 家庭网络做网站wordpress制作网站步骤
  • 西安自助建站公司展示型装饰网站模板
  • 网站推广服务费会计分录怎么做怎么做一个企业网站
  • 如何做网校网站手机做电商怎么赚钱
  • 网站制作职责怎么做正规网站吗
  • 利用google地图标注做网站哈尔滨建设网官方网站
  • 贞丰县住房和城乡建设局网站厦门企业app开发
  • 南宁专业网站开发制作网站免费建站
  • 外贸视频网站开发为什么做电影网站没有流量
  • 网站开发公司 上wordpress网盘搜索
  • 网上做兼职的网站frontpage做内部网站
  • 网页上传和网站开发游戏软件开发公司简介
  • 新乡网站建设制作公司淮北招聘网淮北论坛
  • developer官网下载东莞优化哪家好
  • wordpress说说插件企业网站产品内页优化
  • 做网站的桔子什么品牌推广策略案例
  • 上海兴业建设有限公司网站推荐家居网站建设
  • 音频网站建设做企业网站电话销售话术
  • 郑州好的网站建设公司教育网站制作哪家服务好
  • 南山老品牌网站建设防伪码网站怎么做
  • 公司网站的管理和维护橙色wordpress模板
  • 有哪些好的模板网站睢宁建网站
  • 如何把旅行社网站做的好看一家只做家纺的网站
  • 技术网站源码wordpress新手建什么网站赚钱
  • 凡科论坛网站制作北京做网站维护
  • 如何做一份企业网站规划广州最新新闻头条
  • 扬州公司做网站公司哪家好吗网站建设
  • 公司要做网站做免费漫画网站有风险吗