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

安徽疫情最新消息情况网站seo外包价格

安徽疫情最新消息情况,网站seo外包价格,网站内容全屏截屏怎么做,网站开发和运作的财务预算目录 1. store/index.ts 2. main.ts 3. App.vue调用 4. 如果删除moduleA的namespaced属性, 保留moduleB的namespaced:true 5. 则App.vue修改为: 1. store/index.ts 注意: 需要使用时带上模块名称的namespaced必须为true, 不写或者为false时调用时不需要写模块名称(获取st…

目录

1. store/index.ts

2. main.ts

3. App.vue调用

4. 如果删除moduleA的namespaced属性, 保留moduleB的namespaced:true

5. 则App.vue修改为:


1. store/index.ts

注意: 需要使用时带上模块名称的namespaced必须为true, 不写或者为false时调用时不需要写模块名称(获取state的值必须加模块名)

import { createStore } from "vuex";
// A模块
const moduleA = {namespaced: true,state: {name: "moduleA",},getters: {newName(state) {return state.name;},},mutations: {changeName(state, payload) {state.name = payload;},updateAge(state, playLoad) {state.age = playLoad;},},actions: {changeAge({ commit }, age) {setTimeout(() => {commit("updateAge", age);}, 0);},},
};
// B模块
const moduleB = {namespaced: true,state: {name: "moduleB",age: 33,},getters: {newName(state) {return state.name;},},mutations: {changeName(state, payload) {state.name = payload;},updateAge(state, playLoad) {console.log("playLoad", playLoad);state.age = playLoad;},},actions: {changeAge(ctx, count) {console.log("触发了-模块B的action");setTimeout(() => {ctx.commit("updateAge", count);}, 1000);},},
};
export default createStore({// 分模块modules: {moduleA,moduleB,},
});

2. main.ts

import { createApp } from "vue";
import App from "./App.vue";
import * as Vue from "vue";
import store from './store';const app = createApp(App);
app.use(store);
app.mount("#app");

3. App.vue调用

<template><div id="container"><!-- 1、使用A模块的state数据 --><div>姓名: <input type="text" @change="changeAName($event)"></div><div>年龄: <input type="number" @change="changeAAge($event)"></div><h1>模块a:</h1><p>姓名(state): {{ store.state.moduleA.name }}</p><!-- 2、使用A模块的getters数据 --><p>姓名(getters): {{ store.getters["moduleA/newName"] }}</p><p>年龄: {{ store.state.moduleA.age }}</p><!-- 1、使用B模块的state数据 --><h1>模块b:</h1><div>姓名: <input type="text" @change="changeBName($event)"></div><div>年龄: <input type="number" @change="changeBAge($event)"></div><p>姓名(state): {{ store.state.moduleB.name }}</p><!-- 2、使用B模块的getters数据 $store.getters['模块名/计算属性']--><p>姓名(getters): {{ store.getters["moduleB/newName"] }}</p><p>年龄: {{ store.state.moduleB.age }}</p></div>
</template>
<script setup lang="ts">
import { useStore } from "vuex";// userStore可以拿到vuex仓库实例
const store = useStore();const changeAName = (e) => {store.commit('moduleA/changeName', e.target.value)
};
const changeAAge = (e) => {store.dispatch("moduleA/changeAge", e.target.value)
};const changeBName = (e) => {// 提交B模块的更改store.commit('moduleB/changeName', e.target.value)
};
const changeBAge = (e) => {// 传参用法store.dispatch("moduleB/changeAge", e.target.value)
};
</script>
<style lang='scss' scoped></style>

4. 如果删除moduleA的namespaced属性, 保留moduleB的namespaced:true

import { createStore } from "vuex";
// A模块
const moduleA = {state: {name: "moduleA",},getters: {newName(state) {return state.name;},},mutations: {changeName(state, payload) {state.name = payload;},updateAge(state, playLoad) {state.age = playLoad;},},actions: {changeAge({ commit }, age) {setTimeout(() => {commit("updateAge", age);}, 0);},},
};
// B模块
const moduleB = {namespaced: true,state: {name: "moduleB",age: 33,},getters: {newName(state) {return state.name;},},mutations: {// 更改数据函数changeName(state, payload) {state.name = payload;},updateAge(state, playLoad) {console.log("playLoad", playLoad);state.age = playLoad;},},actions: {changeAge(ctx, count) {setTimeout(() => {ctx.commit("updateAge", count);}, 1000);},},
};
export default createStore({// 分模块modules: {moduleA,moduleB,},
});

5. 则App.vue修改为:

<template><div id="container"><!-- 1、使用A模块的state数据 --><div>姓名: <input type="text" @change="changeAName($event)"></div><div>年龄: <input type="number" @change="changeAAge($event)"></div><h1>模块a:</h1><p>姓名(state): {{ store.state.moduleA.name }}</p><p>姓名(getters): {{ store.getters["newName"] }}</p><p>年龄: {{ store.state.moduleA.age }}</p><!-- 1、使用B模块的state数据 --><h1>模块b:</h1><div>姓名: <input type="text" @change="changeBName($event)"></div><div>年龄: <input type="number" @change="changeBAge($event)"></div><p>姓名(state): {{ store.state.moduleB.name }}</p><!-- 2、使用B模块的getters数据 $store.getters['模块名/计算属性']--><p>姓名(getters): {{ store.getters["moduleB/newName"] }}</p><p>年龄: {{ store.state.moduleB.age }}</p></div>
</template>
<script setup lang="ts">
import { useStore } from "vuex";// userStore可以拿到vuex仓库实例
const store = useStore();const changeAName = (e) => {store.commit('changeName', e.target.value)
};
const changeAAge = (e) => {store.dispatch("changeAge", e.target.value)
};const changeBName = (e) => {store.commit('moduleB/changeName', e.target.value)
};
const changeBAge = (e) => {store.dispatch("moduleB/changeAge", e.target.value)
};
</script>
<style lang='scss' scoped></style>

http://www.zhongyajixie.com/news/24118.html

相关文章:

  • 一站式做网站哪家强网站提交
  • 兰州网站的优化长沙seo免费诊断
  • 长安网站建设哪家好百度投诉中心24人工
  • 公司做彩票网站违法吗网络热词英语
  • 世纪佳缘网站模板企业建站
  • 广安哪里做网站关键词排名优化顾问
  • 西安网站开发培训多少钱移动端优化
  • 设计一个网站代码seo网络推广公司报价
  • 赤水网站建设seo如何优化关键词上首页
  • 高端网站建设 飞沐新闻媒体发稿平台
  • 用网站的源代码怎么做网站站长工具百度百科
  • 如何做个人网站淘宝关键词排名怎么查询
  • 上海网站备案号查询网络事件营销案例
  • 网站设计风格确认书在线友情链接
  • 自己做家具展示网站金泉网做网站多少钱
  • 网站建设策划书ppt宜兴百度推广公司
  • 网站建设平台中央直播如何去做网络推广
  • 做名片最好的网站是哪个软文外链代发
  • 山东省住房城乡建设厅查询网站首页seo视频教程百度云
  • 建设行政主管部门相关网站seo值是什么意思
  • 成都网站建设哪里好点新媒体营销策略
  • ip上海官网北京seo顾问服务
  • 民权县住房和城乡建设局网站seo关键词排名优化的方法
  • 揭阳市榕城区建设局网站十大外贸平台
  • 百度快照是什么百度推广seo效果怎么样
  • 莱州教研室网站外链
  • 招人在哪个网站比较好找广州seo网站优化培训
  • 做食品网站网站排行榜查询
  • 有没有专门做ppt的网站东莞seo优化排名
  • 广东省自然资源厅网站电脑网络优化软件