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

德持建设集团有限公司网站关键词优化的作用

德持建设集团有限公司网站,关键词优化的作用,做网站咋么插入背景图片,做门户网站服务器选择1、Pinia基本概念 1、Pinia向外暴露了几个重要的函数,分别是createPinia、defineStore和storeToRefs 2、pinia有五个核心管理概念: store、store、getters、action、plugins 2、Pinia基本使用 1、安装过程 1、安装pinia插件:npm install pini…

1、Pinia基本概念

1、Pinia向外暴露了几个重要的函数,分别是createPinia、defineStore和storeToRefs

2、pinia有五个核心管理概念:

        store、store、getters、action、plugins

2、Pinia基本使用

1、安装过程

1、安装pinia插件:npm install pinia --save//在main。js中引入,需要调用createPinia()方法将pinia实例化,然后挂载到vue实例上就可以了
2、// 创建pinia状态管理库
import { createPinia } from 'pinia'
const pinia = createPinia()app.use(pinia)

2、简单使用。

defineStore函数用来创建生成store对象的函数,它接收两个参数:第1个参数是store对象的唯一标识,必须保证多个不同的store对象的标识是唯一的;第2个参数是配置对象,基本配置包括state、getters和actions。Pinia要求state配置对象必须是返回state对象的箭头函数,getters是包含多个计算属性的对象,而actions是包含多个action方法的对象。

  2、创建store文件夹,并在其中创建index.js文件,内容如下:需要指定唯一的标识符,这里使用useStore作为标识符:import { defineStore } from 'pinia'export const useStore = defineStore('main', {state: () => ({count: 0}),getters: {doubleCount: (state) => state.count * 2},actions: {increment(state) {state.count++}}})

3、持久化

1、store中的数据,刷新页面后就丢失了,如果想保留这些数据,就要用到数据持久化了。

推荐使用pinia-plugin-persistedstate

2、安装插件

 npm install pinia-plugin-persistedstate

3、引入持久化插件


在mai.js// 创建pinia状态管理库
import { createPinia } from 'pinia'
import piniaPluginPersistedstate from 'pinia-plugin-persistedstate'const pinia = createPinia()
// 引用插件
pinia.use(piniaPluginPersistedstate)

4、开启持久化数据

最后对要实现状态数据持久化的Pinia模块进行持久化的开启配置,比如我们要对计数器模块的count进行持久化处理,只需在counter.js文件中添加persist为true的配置即可。

4、举个例子

1、在store中定义一个一个counter.js文件

const useCounterStore = defineStore('counter', {state: () => ({count: 0,countList: []}),actions: {increment(num) {this.count++;this.countList.push(this.count);},decrement(num) {this.count--;this.countList.push(this.count);},reset() {this.count = 0;this.countList = [];},save() {localStorage.setItem('count', JSON.stringify(this.count));localStorage.setItem('countList', JSON.stringify(this.countList));},},getters: {showCount: (state) => state.count,showCountList: (state) => state.countList,},persist: true,
});export default useCounterStore;

2、在vue组件中使用

<template>
<div>{{ store.count }}
</div>
<div>{{store.showCount}}
</div><div>{{store.countList}}</div><el-button @click="store.increment">+</el-button><el-button @click="store.decrement">-</el-button><el-button @click="store.reset">异步+</el-button>
</template>
<script setup>import useCounterStore from "@/storespinia/counter";
const store = useCounterStore();</script>

5、模块汇总化

1、其中pinia中可以自己归类于一个模块,可以互相不影响,但是也可以通过模块化将相关的模块归集在一起,进行模块的处理化

2、新建立一个index.js

// 统一导出userstore模块
import useCounterStore from "@/storespinia/counter.js";
import userStoreLogin from "@/storespinia/user.js";export default function userStore() {return {counter:useCounterStore(),userLogin:userStoreLogin(),}
}

3、引用模块化

<div>{{ ddd.count }}
</div>
<div>{{ddd.showCount}}
</div><el-button @click="ddd.increment">+</el-button><el-button @click="ddd.decrement">-</el-button><el-button @click="ddd.reset">异步+</el-button><el-button @click="ddd.double">同步+</el-button></template>
<script setup>import userStore from "@/storespinia/index";const store = userStore();
const ddd = store.counter;</script>

http://www.hkea.cn/news/201016/

相关文章:

  • 查企业网站有哪些站长统计app软件
  • 做a高清视频在线观看网站济源新站seo关键词排名推广
  • 刚做的网站怎么搜索不出来百度seo收录软件
  • 视频拍摄app站长工具seo综合查询广告
  • 新闻单位建设网站的意义武汉seo推广优化
  • 低价网站公司软文怎么写
  • 东莞市建设公共交易中心网站百度官网首页
  • 如何建立的网站能争钱优化营商环境 助推高质量发展
  • 做百度网站营销型网站建设排名
  • 网站域名被黑国际新闻最新消息战争
  • 苏州网站开发公司济南兴田德润厉害吗网络自动推广软件
  • 广药网站建设试卷株洲最新今日头条
  • 网站建设管理考核办法微信推广平台怎么做
  • 网站新闻模块代码网络推广有哪些常见的推广方法
  • 合肥大型网站如何推广普通话
  • 高端网站制作软件怎么样推广自己的店铺和产品
  • 无障碍浏览网站怎么做关键词seo排名优化推荐
  • wordpress 247seo推广系统
  • 做深圳门户网站起什么名字好泰州seo外包公司
  • 网站视频上传怎么做百度站长平台论坛
  • wordpress农业模板下载小时seo
  • 做网站语言排名2018发帖推广哪个平台好
  • 销氪crmseo入门讲解
  • 蒙阴哪有做淘宝网站的钓鱼网站制作教程
  • 网站如何做导航条下拉菜单怎么做百度网页
  • 网站开发都做什么平台推广精准客源
  • 网站建设共享ip宁波seo搜索引擎优化
  • 学校网站建设必要性搜索引擎排名
  • 哪里有做区块链网站的百度网址大全在哪里找
  • 加盟平台网站怎么做竞价托管多少钱一个月