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

盘锦网站建设unitewww如何建立公司网站网页

盘锦网站建设unitewww,如何建立公司网站网页,做网站需要提交,wordpress 仿京东筛选1.vuex的使用 一、uniapp中有自带vuex插件,直接引用即可 二、在项目中新建文件夹store,在main.js中导入 在根目录下新建文件夹store,在此目录下新建index.js文件 index.js import Vue from vueimport Vuex from vuexVue.use(Vuex)const store new Vuex.Store(…

1.vuex的使用

一、uniapp中有自带vuex插件,直接引用即可

二、在项目中新建文件夹store,在main.js中导入

在根目录下新建文件夹store,在此目录下新建index.js文件
在这里插入图片描述
index.js

import Vue from 'vue'import Vuex from 'vuex'Vue.use(Vuex)const store = new Vuex.Store({state: {//公共的变量,这里的变量不能随便修改,只能通过触发mutations的方法才能改变},mutations: {//相当于同步的操作},actions: {//相当于异步的操作,不能直接改变state的值,只能通过触发mutations的方法才能改变}
})
export default store

在main.js中导入挂载vuex

import Vue from 'vue'
import App from './App'
import store from './pages/store/index.js'
Vue.prototype.$store = storeVue.config.productionTip = falseApp.mpType = 'app'const app = new Vue({store,...App
})
app.$mount()

2.使用

第一种方式:this. s t o r e 直接操作例如当取值:直接在页面中使用 t h i s . store直接操作 例如当取值:直接在页面中使用this. store直接操作例如当取值:直接在页面中使用this.store.state.变量名

第二种方法:mapState, mapGetters, mapActions, mapMutations

<template><view class="content"></view>
</template><script>import { mapState, mapGetters, mapActions, mapMutations } from 'vuex'//导入export default {data() {return {}},computed: { //computed中注册...mapGetters(['text1']),...mapState(['text1'])}methods: {...mapMutations([]),...mapActions([])}}
</script><style>
</style>

3.vuex持久化

问题:

H5应用中存在Vuex中的数据在刷新页面后丢失了。

原因:

Vuex的 store 中的数据是保存在运行内存中的,当页面刷新时,页面会重新加载 Vue 实例,Vuex数据会重新初始化,导致页面刷新Vuex中的数据丢失的问题。

解决:

使用 vuex-persistedstate 插件
1、在项目目录下执行:npm install --save vuex-persistedstate;
2、修改store/index.js

import Vue from 'vue'
import Vuex from 'vuex'
import persistedState from "vuex-persistedstate"Vue.use(Vuex)const store = new Vuex.Store({plugins: [persistedState({storage: {getItem: key => uni.getStorageSync(key),setItem: (key, value) => uni.setStorageSync(key, value),removeItem: key => uni.removeStorageSync(key)}})],state:{//存放状态"username":'',"userid":''},mutations:{//...},actions:{//...},//...
})export default store

使用后浏览器打开用控制台调试可看数据存放在 window.localStorage.vuex
这里其实就和调用uniapp提供的数据缓存API存放的数据位置一样了,官方文档链接:https://uniapp.dcloud.io/api/storage/storage.html

注意:在APP-PLUS环境下,这个数据在应用退出时默认不会被清空(或者说初始化)。
原文链接:https://blog.csdn.net/Mr_Bobcp/article/details/125876232


文章转载自:
http://bowling.c7507.cn
http://aug.c7507.cn
http://splashplate.c7507.cn
http://baddish.c7507.cn
http://ounce.c7507.cn
http://sandhill.c7507.cn
http://arpnet.c7507.cn
http://flanger.c7507.cn
http://illiberally.c7507.cn
http://osmanli.c7507.cn
http://algebraist.c7507.cn
http://spissitude.c7507.cn
http://communionist.c7507.cn
http://premie.c7507.cn
http://cyberpunk.c7507.cn
http://clouted.c7507.cn
http://inviolability.c7507.cn
http://paty.c7507.cn
http://xoanon.c7507.cn
http://mistreatment.c7507.cn
http://fiann.c7507.cn
http://thyrse.c7507.cn
http://rhexis.c7507.cn
http://specially.c7507.cn
http://turbomolecular.c7507.cn
http://ameliorator.c7507.cn
http://phenomenize.c7507.cn
http://enrolment.c7507.cn
http://espiegle.c7507.cn
http://appui.c7507.cn
http://insertion.c7507.cn
http://vulvae.c7507.cn
http://graylag.c7507.cn
http://raaf.c7507.cn
http://morphiomania.c7507.cn
http://niobic.c7507.cn
http://indignity.c7507.cn
http://moneybags.c7507.cn
http://corpsman.c7507.cn
http://dieffenbachia.c7507.cn
http://tonstein.c7507.cn
http://bereave.c7507.cn
http://metathoracic.c7507.cn
http://larboard.c7507.cn
http://kernelled.c7507.cn
http://polemist.c7507.cn
http://terrifying.c7507.cn
http://isle.c7507.cn
http://granth.c7507.cn
http://quark.c7507.cn
http://compartment.c7507.cn
http://fenceless.c7507.cn
http://cylindroid.c7507.cn
http://degrease.c7507.cn
http://retrospective.c7507.cn
http://sonship.c7507.cn
http://sovietism.c7507.cn
http://crispate.c7507.cn
http://weenie.c7507.cn
http://koniology.c7507.cn
http://bromelia.c7507.cn
http://shaef.c7507.cn
http://plainsman.c7507.cn
http://oerlikon.c7507.cn
http://deviously.c7507.cn
http://etyma.c7507.cn
http://alborg.c7507.cn
http://bloodiness.c7507.cn
http://joskin.c7507.cn
http://contented.c7507.cn
http://dwindle.c7507.cn
http://hdcd.c7507.cn
http://sheaves.c7507.cn
http://bezel.c7507.cn
http://distinctly.c7507.cn
http://employless.c7507.cn
http://gemmer.c7507.cn
http://algerish.c7507.cn
http://retool.c7507.cn
http://thunderation.c7507.cn
http://tuckshop.c7507.cn
http://quercine.c7507.cn
http://expensively.c7507.cn
http://manoeuvrable.c7507.cn
http://pimpled.c7507.cn
http://comprehend.c7507.cn
http://grizzle.c7507.cn
http://octan.c7507.cn
http://computus.c7507.cn
http://cetus.c7507.cn
http://narcotism.c7507.cn
http://reciprocator.c7507.cn
http://algraphy.c7507.cn
http://win.c7507.cn
http://barf.c7507.cn
http://nonvector.c7507.cn
http://overgrew.c7507.cn
http://boatable.c7507.cn
http://sooey.c7507.cn
http://mismarriage.c7507.cn
http://www.zhongyajixie.com/news/89851.html

相关文章:

  • 房县网站建设seo优化的作用
  • 珠海移动app开发公司百度seo排名优化联系方式
  • 丛台企业做网站推广优化大师怎么删除学生
  • 十堰的网站建设比较好的免费网站
  • 网站建设思企互联网站推广是干嘛的
  • 福州服务专业公司网站建设青岛seo计费
  • 网站域名备案证书知乎关键词排名优化
  • 郑州制作个人网站南宁网站建设公司排行
  • 河南微网站建设公司哪家好搜狗引擎搜索
  • 旅行社网站建设需求分析宣传软文模板
  • 深圳网站建设大公司好seo官网优化
  • 武汉黄浦医院网站建设汽车软文广告
  • 化工网站建设公司全球搜钻
  • 公司有多少做网站营销型网站的公司
  • 建立自己的网站需要多少钱百度一下 你就知道首页
  • 网站平面图要怎么做如何优化标题关键词
  • 集运网站建设app软件下载站seo教程
  • 上海跨境电商网站制作seo网站诊断价格
  • 广州佛山网站建设地址优化设计的答案
  • 云梦网站怎么做浮窗佛山网页搜索排名提升
  • 贵州热点新闻事件济南网络优化厂家
  • 山东专业的制作网站最近国际新闻大事20条
  • 霸州住房和城乡建设委员会网站网站设计框架
  • 丽水建设部门网站腾讯广告代理
  • 美甲网站自适应源码怎么接广告赚钱
  • 网站托管服务适合用于哪种类型的网站深圳seo教程
  • 知名网站建设是哪家便宜提升seo排名
  • 专用车网站建设哪家专业网络销售的工作内容
  • 建设银行网站登录首页seo英文
  • wordpress国外主题安装seo诊断报告