Blog
首页
文档
收藏
关于
  • 在线转换时间戳 (opens new window)
  • 在线压缩图片 (opens new window)
  • Float-Double转二进制 (opens new window)
  • 文件转Hex字符串 (opens new window)

HiuZing

🍑
首页
文档
收藏
关于
  • 在线转换时间戳 (opens new window)
  • 在线压缩图片 (opens new window)
  • Float-Double转二进制 (opens new window)
  • 文件转Hex字符串 (opens new window)
  • 前端面试题

  • JavaScript

  • Vue2

  • port

  • CSS

  • Node.js

  • JavaScript优化

  • uniapp

  • Mini Program

  • TypeScript

  • 面向对象编程

  • UI组件

  • Plugin

  • Vue3

  • 性能优化

  • Axios

  • 状态管理

    • pinia

      • Pinia 初始
      • Pinia state
      • Pinia 解构store
      • Pinia Actions
      • Pinia Getters
        • 箭头函数
        • 普通函数
        • 互相调用
      • Pinia API
    • zustand

  • React

  • Mock

  • Icon

  • Template

  • 构建工具

  • 项目规范配置

  • Taro

  • SVG

  • React Native

  • 前端
  • 状态管理
  • pinia
HiuZing
2023-03-27
目录

Pinia Getters

# 箭头函数

不能使用this,this指向已经改变指向undefined,修改值请用state

主要作用类似于computed 数据修饰并且有缓存

getters:{
	newPrice:(state)=>`${state.user.price}`
}
1
2
3

# 普通函数

使用this

//类似于computed 可以帮我们去修饰我们的值
getters: {
    newName():string{
    	return `${this.name}`
    }
}

# 互相调用

getters:{
	newCurrent ():number | string {
		return ++this.current + this.newName
	},
	newName ():string {
		return `$-${this.name}`
	}
},
1
2
3
4
5
6
7
8
上次更新: 2024/08/14, 04:14:33
Pinia Actions
Pinia API

← Pinia Actions Pinia API→

最近更新
01
React Native 使用SVG
08-13
02
Docker基础命令
08-04
03
算数逻辑单元
07-30
更多文章>
Theme by Vdoing | Copyright © 2021-2024 WeiXiaojing | 友情链接
  • 跟随系统
  • 浅色模式
  • 深色模式
  • 阅读模式