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

自己做服务器的网站吗怎么做网络营销推广

自己做服务器的网站吗,怎么做网络营销推广,wordpress跳转www,如何制作网站专题目录 一、vuex概述 1.定义 优势: 2.构建环境步骤 3.state状态 4.使用数据 4.1通过store直接访问 4.2通过辅助函数 5.mutations修改数据(同步操作) 5.1定义 5.2步骤 5.2.1定义mutations对象,对象中存放修改state数据的方…

目录

一、vuex概述

1.定义

优势:

2.构建环境步骤

3.state状态

4.使用数据

4.1通过store直接访问

4.2通过辅助函数

5.mutations修改数据(同步操作)

5.1定义

5.2步骤

5.2.1定义mutations对象,对象中存放修改state数据的方法

5.2.2mutations的传参语法

5.2.3利用辅助函数mapMutations

6.actions异步处理操作

6.1提供actions方法

6.2辅助函数mapActions

7.getters基本语法(没有修改只有获取)

7.1直接通过store访问getters

7.2通过辅助函数mapGetters访问

8.module模块

8.1所以以我们在开发项目过程中, 需要对模块进行拆分--->在store下面新建modules文件夹

8.1.1配置模块文件

8.1.2导入store中并且配置到modules中使用

8.2分模块之后,如何使用模块中的state、mutations、actions以及getters方法

8.2.1直接通过模块名访问

8.2.2通过辅助函数映射---默认跟级别的映射

8.2.3通过辅助函数进行子模块的映射

8.2.4关于actions方法中的context

8.3模块中更推荐的state配置写法


一、vuex概述

1.定义

vuex是一个状态管理工具,可以帮助我们管理vue通用的数据(多组件共享的数据)

优势:

  • 共同维护一份数据,数据集中化管理
  • 响应式变化
  • 操作简洁

2.构建环境步骤

  • 安装vuex----->yarn add vuex@3---->此时用的是vue2所以要使用vuex3的版本
  • 新建store目录文件夹存放单独的js文件存放vuex
  • Vue.use(Vuex)
  • 创建仓库---->cosnt store = new Vuex.Store()
  • 在main.js中导入并且挂载在实例上

通过this.$store访问到仓库---->所有组件都能访问到的通用的对象

3.state状态

1.定义

类似于与vue组件中的data,都是指的数据

2.提供数据

state提供的唯一的公共数据元,所有共享的数据都要统一放到store中的state中存储,在state对象中可以添加我们要共享的数据

const store = new Vuex.Store({state: {//数据}
})

注意:data中的数据是自己的数据,state中的数据是所有组件共享的数据

4.使用数据

通过store直接访问或者通过辅助函数(辅助函数访问更简单)

4.1通过store直接访问

//获取store
import store from '路径'
//利用this.store访问到仓库//在模板中使用
{{ $store.state.xxxx }}//组件逻辑中
this.$store.state.xxxx//js模块中书写方法
store.state.xxxx

4.2通过辅助函数

定义:把state中数据定义在组件内的计算属性中,{{计算属性}},mapState是辅助函数,帮助我们把store中的数据映射到组件的计算属性中

//导入辅助函数
import { mapState } from "vuex"//使用辅助函数,用数组方式引入state
mapState(['变量'])//展开运算符映射到计算属性中
computed:{ ...mapState(['变量']) }

5.mutations修改数据(同步操作)

5.1定义

明确vuex同样的遵循单向数据流,组件中不能修改仓库中的数据

通过strict:true,可以开启严格模式(在其他组件中直接修改仓库中的数据会报错,在最终上线的时候不用开启严格模式。因为严格模式是为了更好的提醒程序员出错点以及原因便于修改)

若是想要修改state中的数据那么只能通过mutations

5.2步骤

5.2.1定义mutations对象,对象中存放修改state数据的方法
const store = new Vuex.Store({state:{....},mutations:{mutations函数名(state){  //state.数据修改逻辑}}
})//组件中调用
this.$store.commit('mutations函数名')
5.2.2mutations的传参语法
//传递一个参数的情况
const store = new Vuex.Store({state:{....},mutations:{mutations函数名(state,参数){  //state.数据修改逻辑}}
})//组件中调用
this.$store.commit('mutations函数名',参数)//传递多个参数则采用对象模式
const store = new Vuex.Store({state:{....},mutations:{mutations函数名(state,obj){  //state.数据修改逻辑}}
})//组件中调用
this.$store.commit('mutations函数名',{参数1:值1,参数2:值2....})
5.2.3利用辅助函数mapMutations

mapMutations本质上就是把mutations中的方法提取出来,映射到组件的methods中

//在mutations中提供方法
const store = new Vuex.Store({state:{....},mutations:{mutations函数名(state,参数){  //state.数据修改逻辑}}
})//映射到组件的methods中
import { mapMutations } from 'vuex'
methods:{ ...mapMutations(['mutations函数名']) 
}//组件中调用
this.函数名(参数)    //可以直接利用click点击直接调用并传参

6.actions异步处理操作

6.1提供actions方法

//提供actions方法
const store = new Vuex.Store({state:{....},mutations:{....},actions:{actions函数名(context,参数){//异步处理逻辑(如发请求)}}
})//页面中调用
this.$store.dispath('actions函数名',参数)

actions处理异步操作但是并不会直接操作state,如果想要修改state,需要调用mutations方法

----->context.commit('mutations函数名',额外参数)

6.2辅助函数mapActions

同mutations一样,直接映射到组件中的methods中,可以直接调用

//在mutations中提供方法
const store = new Vuex.Store({state:{....},mutations:{....},actions:{actions函数名(context,参数){//异步处理逻辑(如发请求)}}
})//映射到组件的methods中
import { mapActions } from 'vuex'
methods:{ ...mapActions(['actions函数名']) 
}//组件中调用
this.函数名(参数)

7.getters基本语法(没有修改只有获取)

有时候需要从state中派生出一种状态,这些状态时依赖于state的,此时就会用到getters

7.1直接通过store访问getters

//提供actions方法
const store = new Vuex.Store({state:{....},mutations:{....},actions:{....},getters:{getters函数名(state){//处理逻辑return getters计算结果}}
})//页面模板中通过store访问getters
{{ $store.getters.getters函数名 }}

7.2通过辅助函数mapGetters访问

//提供actions方法
const store = new Vuex.Store({state:{....},mutations:{....},actions:{....},getters:{getters函数名(state){//处理逻辑return getters计算结果}}
})//映射到组件的methods中
import { mapGetters } from 'vuex'
computed:{ ...mapGetters(['getters函数名']) 
}//组件中调用
{{ getters函数名 }}

四个辅助函数记忆:

  • mapState 和 mapGetters 是在映射属性
  • mapMutations 和 mapActions 是在映射方法

8.module模块

由于vuex是使用单一状态树,应用的所有状态会集中到一个比较大的对象,当应用变得非常复杂时,state对象就可能变得臃肿且难以维护。

8.1所以以我们在开发项目过程中, 需要对模块进行拆分--->在store下面新建modules文件夹

8.1.1配置模块文件
//在模块文件中//配置state数据对象
cosnt state = {数据:{key:value,key1:value,...}
}//配置mutations方法
const mutations = {},//actions方法
const actions = {},//配置getters方法
const getters = {}//导出配置对象
export default {state,mutations,actions,getters
}
8.1.2导入store中并且配置到modules中使用
//导入store中import 文件名 from '路径'//配置modules对象const store = new Vue.Store({modules:{文件名,...}
})

8.2分模块之后,如何使用模块中的state、mutations、actions以及getters方法

分模块之后,各模块的辅助函数的参数state时指代子模块中的state

8.2.1直接通过模块名访问
//直接通过模块名访问state$store.state.模块名.xxx//直接通过模块名访问getters$store.getters['模块名/xxx']//直接通过模块名访问mutations$store.commit('模块名/xxx',额外参数)//直接通过模块名访问actions$store.dispatch('模块名/xxx',额外参数)
8.2.2通过辅助函数映射---默认跟级别的映射
//直接通过mapState访问state----默认根级别的映射mapState(['xxx'])//直接通过mapGetters访问getters----默认根级别的映射mapGetters(['xxx'])//直接通过mapMutations访问mutations----默认根级别的映射mapMutations(['xxx'])//直接通过mapActions访问actions----默认根级别的映射mapActions(['xxx'])
8.2.3通过辅助函数进行子模块的映射
//需要在子模块中开启命名空间namespaced:true//直接通过mapState访问state----子模块的映射mapState('模块名',['xxx'])//直接通过mapGetters访问getters----子模块的映射mapGetters('模块名',['xxx'])//直接通过mapMutations访问mutations----子模块的映射mapMutations('模块名',['xxx'])//直接通过mapActions访问actions----子模块的映射mapActions('模块名',['xxx'])
8.2.4关于actions方法中的context

context是上下文的意思,默认提交的就是自己模块的actions和mutations方法,基于当前模块环境指向不同的空间

8.3模块中更推荐的state配置写法

export default {namespaced:true,state () {    //利用函数的形式存储数据使其更加具有独立性return {//数据}}
}


文章转载自:
http://arboraceous.c7623.cn
http://dogmatical.c7623.cn
http://rhubarb.c7623.cn
http://cupronickel.c7623.cn
http://comeliness.c7623.cn
http://revetment.c7623.cn
http://hypoglycemia.c7623.cn
http://adamantane.c7623.cn
http://hemitrope.c7623.cn
http://leewardly.c7623.cn
http://entirely.c7623.cn
http://subalpine.c7623.cn
http://teaser.c7623.cn
http://shell.c7623.cn
http://lazy.c7623.cn
http://duteous.c7623.cn
http://sogat.c7623.cn
http://impermanent.c7623.cn
http://sorceress.c7623.cn
http://igorot.c7623.cn
http://hypergamy.c7623.cn
http://moroni.c7623.cn
http://refectioner.c7623.cn
http://guzzle.c7623.cn
http://canaanitic.c7623.cn
http://epithet.c7623.cn
http://coparcener.c7623.cn
http://shaktism.c7623.cn
http://bauchle.c7623.cn
http://tyrosinase.c7623.cn
http://repatriate.c7623.cn
http://nonagricultural.c7623.cn
http://shucks.c7623.cn
http://hairpiece.c7623.cn
http://vacuole.c7623.cn
http://adversaria.c7623.cn
http://automatism.c7623.cn
http://chromiderosis.c7623.cn
http://bucolic.c7623.cn
http://calceolaria.c7623.cn
http://musketry.c7623.cn
http://planiform.c7623.cn
http://cappelletti.c7623.cn
http://mercer.c7623.cn
http://amygdule.c7623.cn
http://voyager.c7623.cn
http://documentarian.c7623.cn
http://luxemburg.c7623.cn
http://trichoma.c7623.cn
http://nature.c7623.cn
http://fruity.c7623.cn
http://gelation.c7623.cn
http://mummer.c7623.cn
http://lavishness.c7623.cn
http://untimeliness.c7623.cn
http://dinge.c7623.cn
http://ecumenist.c7623.cn
http://cryophyte.c7623.cn
http://reforestation.c7623.cn
http://operatise.c7623.cn
http://intussuscept.c7623.cn
http://minority.c7623.cn
http://xerogram.c7623.cn
http://villein.c7623.cn
http://puma.c7623.cn
http://synopsize.c7623.cn
http://tabernacle.c7623.cn
http://semiliteracy.c7623.cn
http://camisa.c7623.cn
http://fixing.c7623.cn
http://cosmogeny.c7623.cn
http://salubrity.c7623.cn
http://speak.c7623.cn
http://chirp.c7623.cn
http://impaste.c7623.cn
http://elgin.c7623.cn
http://creta.c7623.cn
http://dragonesque.c7623.cn
http://demirelievo.c7623.cn
http://compounding.c7623.cn
http://breakup.c7623.cn
http://dino.c7623.cn
http://cheeseparing.c7623.cn
http://rich.c7623.cn
http://xtra.c7623.cn
http://camerawork.c7623.cn
http://gaullist.c7623.cn
http://triene.c7623.cn
http://titubation.c7623.cn
http://apolline.c7623.cn
http://ieee.c7623.cn
http://wuzzy.c7623.cn
http://supracrustal.c7623.cn
http://berserker.c7623.cn
http://caseworm.c7623.cn
http://mirepoix.c7623.cn
http://feud.c7623.cn
http://unswathe.c7623.cn
http://fructosan.c7623.cn
http://surveyor.c7623.cn
http://www.zhongyajixie.com/news/83566.html

相关文章:

  • 哪里接单做网站成都网站seo公司
  • 自己免费做网站(三)吸引人气的营销方案
  • 电子商务网站建设与管理实训报告刷关键词怎么刷
  • 网页qq直接登陆茂名seo快速排名外包
  • 如何做优秀的游戏视频网站网络推广员岗位职责
  • 免费域名网站php域名解析网站
  • 简单网站建设软件有哪些方面电商平台推广
  • 江宁网站建设价位谷歌关键词搜索排名
  • 网站开发和安卓开发百度网盘搜索
  • 做网站常用工具软文广告300字范文
  • 油画风网站艾瑞指数
  • 怎样在阿里做网站免费网址注册
  • 软件外包合同保定百度首页优化
  • 网站的前期推广seo服务工程
  • 制作网站的免费软件网络营销员岗位的职责与要求
  • 做网站怎么调用栏目百度注册
  • 重庆金山建设监理有限公司网站网站制作代码
  • 网赌网站怎么做亚马逊关键词排名提升
  • 做美女写真网站犯法吗百度视频免费高清影视
  • 直播网站建设需要什么seo关键词平台
  • 图片制作视频怎么制作百度seo是啥
  • 南宁市网站开发建设网站seo培训
  • 建设公司网站管理制度的意义代写
  • 沈阳网站制作方法网站搜索优化方法
  • 网站建设文献翻译qq营销推广方法和手段
  • 成品直播app源码seo新站如何快速排名
  • 网站用什么技术做的2023新闻热点事件
  • 衡阳做网站优化免费网站java源码大全
  • 网站怎样续费推广工具有哪些
  • 网站开发上线流程短视频询盘获客系统