五月天青色头像情侣网名,国产亚洲av片在线观看18女人,黑人巨茎大战俄罗斯美女,扒下她的小内裤打屁股

歡迎光臨散文網(wǎng) 會(huì)員登陸 & 注冊

pina使用步驟

2023-04-24 10:59 作者:小戶編程  | 我要投稿

安裝pina庫

在命令行中為該項(xiàng)目安裝pinia

npm install pina

vue安裝pinia

在main.js入口文件中導(dǎo)入pinia的創(chuàng)建函數(shù),vue實(shí)例中使用pinia

import?{ createPinia?} from?'pinia'

app.use(createPinia())


?

定義狀態(tài)

創(chuàng)建/src/stores文件夾,創(chuàng)建一個(gè)狀態(tài)管理js,例如計(jì)數(shù)器

/src/stores/counter.js

import?{ defineStore?} from?"pinia";

?

export?const?useCounterStore?= defineStore("counter", {

? state:?() =>?{

? ? return?{ count:?0?};

? },

? // 也可以這樣定義

? // state: () => ({ count: 0 })

? actions:?{

? ? increment() {

? ? ? this.count++;

? ? }

? }

});

使用狀態(tài)

先引入,然后調(diào)用狀態(tài)的屬性和方法。

<template>

? <div>{{ counter.count?}}</div>

</template>

<script?setup>

import?{ useCounterStore?} from?"@/stores/counter";

?

const?counter?= useCounterStore();

counter.count++;

counter.increment();

</script>

<style></style>

?


pina使用步驟的評(píng)論 (共 條)

分享到微博請(qǐng)遵守國家法律
布尔津县| 磐石市| 渝北区| 汨罗市| 宁城县| 宁河县| 荃湾区| 大同县| 绥中县| 南安市| 龙里县| 洪洞县| 阿拉尔市| 连州市| 根河市| 宾川县| 内乡县| 正镶白旗| 新竹县| 若尔盖县| 方城县| 故城县| 炉霍县| 太仆寺旗| 漳浦县| 旬阳县| 理塘县| 德钦县| 茂名市| 会泽县| 明光市| 雅安市| 泊头市| 彭泽县| 金塔县| 平原县| 会东县| 石楼县| 耿马| 嘉兴市| 溆浦县|