您好,在将内联 svgs 导入到我的 nuxt3 vite 项目中时遇到了麻烦。任何建议将不胜感激。
我发现这可行 <img src="~/assets/images/icons/push-icon-chatops.svg" />,但我需要一个内联项目。所以我会做这样的事情<div v-html="rawNuxtLogo" />并做这样的事情(require在vite中不起作用)。
setup(props) {
const currentIcon = computed(() => {
return defineAsyncComponent(() =>
import(`~/assets/images/icons/push-icon-chatops.svg'?inline`)
);
}).value;
return {
currentIcon,
};
},
Run Code Online (Sandbox Code Playgroud)
但是我发现 vite 确实奇怪地导入,结果要么是 v-html 中显示的 url 字符串,要么是一个无法读取的对象
我正在尝试使用这个插件但没有成功。
自 nuxt 3.4.0 更新以来,pinia 存储不能再在可组合项中使用。
//example composable
import { useAuthStore } from '~/store/auth-store';
const authStore = useAuthStore();
export function doSomethingWithStore() {
return authStore.checkAuthUser;
}
Run Code Online (Sandbox Code Playgroud)
您现在将收到以下错误
getActivePinia was called with no active Pinia. Did you forget to install pinia? const pinia = createPinia() app.use(pinia) This will fail in production.
Run Code Online (Sandbox Code Playgroud)
请参阅 stackblitz 示例 https://stackblitz.com/edit/broken-pinia-store-in-composeables?file=composables%2FthisBreaks.js,nuxt.config.ts