中文亚洲精品无码_熟女乱子伦免费_人人超碰人人爱国产_亚洲熟妇女综合网

當(dāng)前位置: 首頁 > news >正文

java 做直播網(wǎng)站排名優(yōu)化課程

java 做直播網(wǎng)站,排名優(yōu)化課程,濟(jì)南市規(guī)劃局官網(wǎng),如何制作ppt課件系列文章目錄 第八章 Pinia 文章目錄 系列文章目錄前言一、安裝和配置:二、基本使用三、一個(gè)更真實(shí)的例子 前言 Pinia是Vue.js應(yīng)用程序的狀態(tài)管理庫。它提供了一種簡(jiǎn)單,輕量級(jí)的解決方案,用于在Vue應(yīng)用程序中管理和維護(hù)狀態(tài)。Pinia庫的特點(diǎn)…

系列文章目錄

第八章 Pinia


文章目錄

  • 系列文章目錄
  • 前言
  • 一、安裝和配置:
  • 二、基本使用
  • 三、一個(gè)更真實(shí)的例子


前言

Pinia是Vue.js應(yīng)用程序的狀態(tài)管理庫。它提供了一種簡(jiǎn)單,輕量級(jí)的解決方案,用于在Vue應(yīng)用程序中管理和維護(hù)狀態(tài)。Pinia庫的特點(diǎn)是易于使用和集成,可以使開發(fā)者在不犧牲性能的情況下更有效地處理和維護(hù)狀態(tài)。pinia中有三個(gè)概念,分別是:state、getter、action,對(duì)應(yīng)于Vue組件中的:data、computed、methods。


一、安裝和配置:

安裝:通過命令:npm install pinia@2.1.7 ,或者在創(chuàng)建vue項(xiàng)目的時(shí)候勾選使用Pinia。
配置:在main.js中,需要?jiǎng)?chuàng)建pinia對(duì)象,并與app對(duì)象進(jìn)行綁定,示例代碼如下:

import { createApp } from 'vue'
import { createPinia } from 'pinia'import App from './App.vue'const app = createApp(App)
app.use(createPinia())
app.mount('#app')

二、基本使用

通常在src目錄下創(chuàng)建一個(gè)stores文件夾,然后在里面按需創(chuàng)建js文件。假設(shè)要?jiǎng)?chuàng)建一個(gè)用于管理counter全局變量的庫文件,那么可以創(chuàng)建counter.js文件,然后填入以下代碼:

import { defineStore } from 'pinia'export const useCounterStore = defineStore('counter', () => {const count = ref(0)function increment() {count.value++}return { count, increment }
})

或者使用選項(xiàng)式API:

import { defineStore } from 'pinia'export const useCounterStore = defineStore('counter', {state: () => {return { count: 0 }},// 也可以這樣定義// state: () => ({ count: 0 })actions: {increment() {this.count++},},
})

這樣就定義好了一個(gè)count變量,以后在組件中可以通過以下三種方式修改:

<script setup>
import { useCounterStore } from '@/stores/counter'
const counterStore = useCounterStore()
// 1. 直接修改
counterStore.count++
// 2. 使用$patch批量修改
counterStore.$patch({ count: counterStore.count + 1 })
// 3. 使用action修改
counterStore.increment()
</script>
<template><!-- 直接從 store 中訪問 state --><div>Current Count: {{ counter.count }}</div>
</template>

以上三種修改方式的應(yīng)用場(chǎng)景如下:

  1. 如果只要修改一個(gè)狀態(tài)變量,并且不需要額外的操作,那么推薦使用第一種方法。
  2. 如果要一次性修改多個(gè)狀態(tài)變量,那么推薦使用$patch方法,效率更高。
  3. 如果在修改狀態(tài)變量的同時(shí)要做一些額外的操作,那么推薦第三種方法。

三、一個(gè)更真實(shí)的例子

import { defineStore } from 'pinia'
export const useTodos = defineStore('todos', {state: () => ({/** @type {{ text: string, id: number, isFinished: boolean }[]} */todos: [],/** @type {'all' | 'finished' | 'unfinished'} */filter: 'all',// 類型將自動(dòng)推斷為 numbernextId: 0,}),getters: {finishedTodos(state) {return state.todos.filter((todo) => todo.isFinished)},unfinishedTodos(state) {return state.todos.filter((todo) => !todo.isFinished)},/*** @returns {{ text: string, id: number, isFinished: boolean }[]}*/filteredTodos(state) {if (this.filter === 'finished') {// 調(diào)用其他帶有自動(dòng)補(bǔ)全的 getters ?return this.finishedTodos} else if (this.filter === 'unfinished') {return this.unfinishedTodos}return this.todos},},actions: {// 接受任何數(shù)量的參數(shù),返回一個(gè) Promise 或不返回addTodo(text) {// 你可以直接變更該狀態(tài)this.todos.push({ text, id: this.nextId++, isFinished: false })},},
})

http://www.risenshineclean.com/news/4807.html

相關(guān)文章:

  • wordpress瀏覽量排序seo標(biāo)題生成器
  • 開發(fā)網(wǎng)站賺錢今日關(guān)鍵詞
  • 做學(xué)校網(wǎng)站素材圖片大全百度網(wǎng)盤搜索引擎盤多多
  • .net雙拼做公司網(wǎng)站臨沂做網(wǎng)站建設(shè)公司
  • 網(wǎng)管軟件定制開發(fā)北京網(wǎng)站優(yōu)化技術(shù)
  • 中原建設(shè)信息網(wǎng) 網(wǎng)站品牌營銷方案
  • 湖南網(wǎng)站建設(shè)小公司近期的新聞消息
  • 國際網(wǎng)站建設(shè)招標(biāo)關(guān)鍵詞統(tǒng)計(jì)工具有哪些
  • 清遠(yuǎn)做網(wǎng)站哪家好mac日本官網(wǎng)入口
  • 西安網(wǎng)站建設(shè)專業(yè)公司重慶網(wǎng)站優(yōu)化軟件
  • 海東市城市規(guī)劃建設(shè)局網(wǎng)站合肥seo優(yōu)化
  • hao123網(wǎng)站模板百度網(wǎng)站介紹
  • 做海報(bào)創(chuàng)意網(wǎng)站排行榜前十名
  • 網(wǎng)站建設(shè)收費(fèi)報(bào)價(jià)表中國去中心化搜索引擎
  • 微信官網(wǎng)網(wǎng)站模板下載不了愛站網(wǎng)關(guān)鍵詞排名
  • 焦作網(wǎng)站建設(shè)哪家權(quán)威青島谷歌推廣
  • 電子商務(wù)網(wǎng)站的建設(shè)報(bào)告百度學(xué)術(shù)搜索
  • 省政府網(wǎng)站建設(shè)標(biāo)準(zhǔn)營銷網(wǎng)站定制公司
  • 域名到期換個(gè)公司做網(wǎng)站深圳seo公司
  • 網(wǎng)絡(luò)營銷策劃實(shí)訓(xùn)報(bào)告路由優(yōu)化大師官網(wǎng)
  • 文化建設(shè) 設(shè)計(jì)公司網(wǎng)站如何做網(wǎng)絡(luò)推廣
  • 達(dá)州市建設(shè)規(guī)劃網(wǎng)站成人再就業(yè)培訓(xùn)班
  • 政府網(wǎng)站集約化建設(shè)經(jīng)驗(yàn)百度入口官網(wǎng)
  • 培訓(xùn)教育行業(yè)網(wǎng)站建設(shè)方案中國營銷網(wǎng)站
  • 何炅做的代言網(wǎng)站推廣優(yōu)化
  • wordpress添加一個(gè)論壇seo優(yōu)化快速排名
  • 杭州移動(dòng)網(wǎng)站建設(shè)搜外友鏈平臺(tái)
  • 門戶網(wǎng)站定制服務(wù)品牌互動(dòng)營銷案例
  • 攻擊自己做的網(wǎng)站bt螞蟻磁力
  • 小廣告怎么舉報(bào)網(wǎng)站排名優(yōu)化公司哪家好