Nuxt plugins 機能を利用して登録されたHelperを用いて状態を管理します。
Nuxt plugins機能を利用して登録されたHelperを用いて状態を管理します。
URI | helper://{**path} |
---|---|
Scheme | helper |
Path | Nuxt plugins Helper へのパスとファイル名を指定します。 |
Example | helper://{**path} |
Nuxt pluginsを登録します。
主にActionとTransformで利用されることを想定しています。
import type { ICombadgeNuxtHelperProps } from "../../src/runtime/composables/useCombadgeHelper"
export default defineNuxtPlugin(() => {
return {
provide: {
counter: (props: ICombadgeNuxtHelperProps) => {
console.log(props)
switch (props.method) {
case "get":
throw new Error("NotSupported");
case "set":
throw new Error("NotSupported");
case "action":
{
const parsed = parseInt(props.data) || 0
switch (props.params) {
case "up":
return parsed + 1
case "down":
return parsed - 1
}
break;
}
}
return props.data;
}
}
}
})