SvelteKit:无法引用 <script context="module" /> 内的存储值
SvelteKit: Cannot reference store value inside <script context="module" />
SvelteKit / Svelte:无法从上下文模块中的“存储”获取或设置(读取或写入)值。
import {selectedStore} from "src/storelocation";
<script context="module">
export const load = async ({params})=> {
$selectedStore.value // throwing error
}
import {selectedStore} from "src/storelocation";
import { get } from 'svelte/store';
<script context="module">
export const load = async ({params})=> {
// use this
get(selectedStore).value;
}
SvelteKit / Svelte:无法从上下文模块中的“存储”获取或设置(读取或写入)值。
import {selectedStore} from "src/storelocation";
<script context="module">
export const load = async ({params})=> {
$selectedStore.value // throwing error
}
import {selectedStore} from "src/storelocation";
import { get } from 'svelte/store';
<script context="module">
export const load = async ({params})=> {
// use this
get(selectedStore).value;
}