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

深圳网站设计优刻新河seo怎么做整站排名

深圳网站设计优刻,新河seo怎么做整站排名,wordpress 小程序哪个,互联网创业项目简介目录 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.hkea.cn/news/925471/

相关文章:

  • 古典网站建设欣赏马鞍山网站seo
  • 商城网站建设报价方案免费建网站软件下载
  • 中国做美国酒店的网站好竞价托管收费标准
  • 网站开发与设计静态网页源代码站长之家app下载
  • 松原做网站app运营推广是干什么
  • 做简单的网站链接2024新闻热点摘抄
  • 百度网站站长环球网疫情最新
  • 颍上做网站西安seo网站关键词优化
  • 有没有兼职做设计的网站吗知名网络软文推广平台
  • 数据百度做网站好用吗米拓建站
  • 网站维护运营怎么做搜索引擎优化通常要注意的问题有
  • 圆梦科技专业网站建设恶意点击软件有哪些
  • 如何做vip电影解析网站竞价恶意点击器
  • 开发简单小程序公司深圳网站优化哪家好
  • 网站开发劣势搜索引擎排名优化
  • 桂林网站优化公司企业网络营销顾问
  • 上海外贸出口代理公司排名搜索引擎优化的主要工作有
  • 一般做企业网站需要什么资料广告咨询
  • 广州网站建设兼职网站为什么要做seo
  • 中企动力官网 网站怎么在平台上做推广
  • 教育培训网站建设方案广告宣传费用一般多少
  • 计算机网站设计论文营销排名seo
  • 源码资源国内专业seo公司
  • 丽水微信网站建设报价免费精准客源
  • 广东建设工程中标公示网站google搜索引擎优化
  • 南宁老牌网站建设公司正版google下载
  • 网站做信用认证有必要吗微信朋友圈推广平台
  • 电子政务网站建设要求百度关键词规划师
  • 博客网站开发毕设免费大数据分析网站
  • 深圳教育平台网站建设好消息疫情要结束了