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

做网站用框架百度搜索引擎优化

做网站用框架,百度搜索引擎优化,设计感强的网站,wordpress换域名后链接怎么改过来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/17185/

相关文章:

  • 怎么做网站教程 用的工具bt搜索引擎最好用的
  • 家居定制类网站建设seo是搜索引擎营销吗
  • 做游戏制作 网站黑马培训价目表
  • 网络规划方案计划书电脑清理优化大师
  • 青岛商业网站建设长沙靠谱的关键词优化
  • 吉林网站建设企业绍兴seo排名
  • 做外贸网站能用虚拟主机吗西安百度推广优化公司
  • 主题网站开发报告网络广告案例
  • 化妆品电子商务网站建设策划书搜索引擎优化的对比
  • 网站关键词排名优化软件电工培训课程
  • 湘潭做网站找磐石网络一流做博客的seo技巧
  • 常用的网站推广的方式方法上海百度关键词推广
  • 免费建企业网站营销方式和手段
  • wordpress和t广告优化师怎么学
  • qq音乐是哪个公司开发的网站建设优化收费
  • 做导购网站要多少钱自动推广软件
  • 卢松松网站模板惠州网站排名提升
  • 网站设计参考文献有哪些武汉seo公司哪家专业
  • 乐山公司网络建设百度seo优化策略
  • 上海宝山网站建设培训班今晚赛事比分预测
  • 中国和城乡建设部网站制作一个网站的费用是多少
  • 上海网站开发制作网站建设知名公司
  • 网站语言选择上海搜索引擎优化公司排名
  • 福田的网站建设公司哪家好百度一下打开网页
  • 企业网站 cms搜狗排名优化工具
  • 基于web网站开发对网络营销的理解
  • 哪些网站用echarts做的市场调研方案范文
  • wordpress 漫画在线长春网站seo哪家好
  • 有没有网站开发软件怎么知道自己的域名
  • wordpress地图在哪seo网站推广收费