baiyuetribe / nuxt3-naive-ui-starter Goto Github PK
View Code? Open in Web Editor NEWA starter example for naive-ui with nuxt3.
Home Page: https://nuxt3-naive-ui.netlify.app
License: MIT License
A starter example for naive-ui with nuxt3.
Home Page: https://nuxt3-naive-ui.netlify.app
License: MIT License
由于Nuxt3官方文档案例极少,尝鲜起来坑很多,愿意折腾的可以加群互相答疑。
该问题开发和构建时都无影响,只是有时候可能会有UI错位问题。
[3/4] Linking dependencies...
warning " > [email protected]" has unmet peer dependency "vue@^3.0.0".
warning "naive-ui > @css-render/[email protected]" has unmet peer dependency "vue@^3.0.11".
warning "naive-ui > [email protected]" has unmet peer dependency "vue@^3.0.11".
warning "naive-ui > [email protected]" has unmet peer dependency "vue@^3.0.0".
warning "naive-ui > [email protected]" has unmet peer dependency "vue@^3.0.11".
warning "nuxt3 > @nuxt/vite-builder > [email protected]" has unmet peer dependency "postcss@^8.1.0".
warning "nuxt3 > @nuxt/vite-builder > [email protected]" has unmet peer dependency "postcss@^8.0.0".
warning "nuxt3 > @nuxt/vite-builder > [email protected]" has unmet peer dependency "postcss@^8.0.0".
warning " > [email protected]" has unmet peer dependency "vue@2 || 3".
[4/4] Building fresh packages...
以上来自vercel构建日志,演示站https://naiveui-nuxt3-kk2l4botq-baiyuetribe.vercel.app/
在nuxt.config.ts里
import { defineNuxtConfig } from 'nuxt3'
// https://v3.nuxtjs.org/docs/directory-structure/nuxt.config
export default defineNuxtConfig({
vite: {
build: {
cssCodeSplit: false, // 测试css会生成,但是页面丢失
}
},
})
打包后,.output里确实有单独的css文件生成,但是页面访问后css样式未被引入
服务端报错但不影响使用的组件有:
其余组件一律OK。凡是调用document的报错演示地址 https://stackblitz.com/edit/github-63jd1t-2gyt1u?file=app.vue
奇怪现象:虽然报错,但是用户浏览器一切正常运行。如果能搞定node环境下无法识别document或关闭nuxt3的日志,或可用于正式产品,否则以上这些组件暂时不能使用。
Nuxt3 currently gives the useFetch and useAsyncData data acquisition method is triggered twice, which directly blocked the door to separate front and back-end development. Since the server has already got the data, why does the client have to get it again and again?
Nuxt3目前给出的useFetch和useAsyncData数据获取方式都是触发两次的,这下直接堵上了前后端分离开发的大门。既然服务端已经拿到了数据,为何客户端还要再重复获取一遍?都beta版了,这么重要的问题都没处理好,泪奔啊
nuxt/nuxt#13369
Hello ! Thanks for the great work. Using your module alone works fine but I am having a hard time integrating it to my project that uses modules (supabase integration).
Nuxt CLI v3.0.0-27409835.c53c736 11:57:10
RootDir: /media/workspace/code/nuxt3-naive-ui-starter 11:57:11
Nuxt project info: 11:57:11
------------------------------
- Operating System: `Linux`
- Node Version: `v17.3.0`
- Nuxt Version: `3.0.0-27409835.c53c736`
- Package Manager: `[email protected]`
- Bundler: `Vite`
- User Config: `build`, `vite`, `buildModules`, `supabase`
- Runtime Modules: `-`
- Build Modules: `@larbish/[email protected]`
------------------------------
https://stackblitz.com/edit/github-9zcuqu?file=app.vue
When adding supabase module with the following instructions, automatic import of naiveui components don't work anymore. I have to manually import everything.
I wonder if @css-render/vue3-ssr plays well with Nuxt3 ? Do you have an idea what could cause this error ?
[Vue warn]: Failed to resolve component: n-result
If this is a native custom element, make sure to exclude it from component resolution via compilerOptions.isCustomElement.
[Vue warn]: Failed to resolve component: n-button
If this is a native custom element, make sure to exclude it from component resolution via compilerOptions.isCustomElement.
[Vue warn]: Failed to resolve component: n-space
If this is a native custom element, make sure to exclude it from component resolution via compilerOptions.isCustomElement.
[Vue warn]: Failed to resolve component: n-h2
If this is a native custom element, make sure to exclude it from component resolution via compilerOptions.isCustomElement.
[Vue warn]: Failed to resolve component: n-tooltip
[...]
(node:13) UnhandledPromiseRejectionWarning: TypeError: Invalid value used as weak map key
at WeakMap.set (<anonymous>)
at normalizePropsOptions (/home/projects/github-9zcuqu/node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:3384:11)
at createComponentInstance (/home/projects/github-9zcuqu/node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:6851:23)
at renderComponentVNode (/home/projects/github-9zcuqu/node_modules/@vue/server-renderer/dist/server-renderer.cjs.js:197:22)
at Module.ssrRenderComponent (/home/projects/github-9zcuqu/node_modules/@vue/server-renderer/dist/server-renderer.cjs.js:629:12)
at _sfc_ssrRender (file:///home/projects/github-9zcuqu/.nuxt/dist/server/server.mjs:7330:31)
at renderComponentSubTree (/home/projects/github-9zcuqu/node_modules/@vue/server-renderer/dist/server-renderer.cjs.js:269:13)
at renderComponentVNode (/home/projects/github-9zcuqu/node_modules/@vue/server-renderer/dist/server-renderer.cjs.js:214:16)
at Module.ssrRenderComponent (/home/projects/github-9zcuqu/node_modules/@vue/server-renderer/dist/server-renderer.cjs.js:629:12)
at default (file:///home/projects/github-9zcuqu/.nuxt/dist/server/server.mjs:7224:35)
Hi,
FYI : When opening the live demo page, I'm seeing a "500 - document is not defined"
解决方案,使用yarn重新打包。nuxt3虽然日更十多次,但是头疼的问题不少。
(node:93509) Warning: To load an ES module, set "type": "module" in the package.json or use the .mjs extension.
(Use `node --trace-warnings ...` to show where the warning was created)
ERROR [worker] Worker terminated due to reaching memory limit: JS heap out of memory
at new NodeError (node:internal/errors:371:5)
at Worker.[kOnExit] (node:internal/worker:276:26)
at Worker.<computed>.onexit (node:internal/worker:198:20)
关闭ssr使用客户端渲染显示正常;开启ssr服务端渲染后不正常,但是只要稍微缩放下浏览器窗口就恢复正常。
示例:https://naiveui-nuxt3.vercel.app
文档给出的在head中添加meta,貌似不是针对nuxt的,我在配置文件添加了meta无效
Great work on getting naive-ui to work with nuxt 3, but hot-reload is not working.
While using your boilerplate, a page with
<template>
<h1>Naive-UI</h1>
<n-button>Button</n-button>
</template>
fails to hot-reload, but any other page without naive-ui elements hot-reloads.
这种覆盖是全局的,包括nuxt.config.ts
里定义的全局js。
在nuxt3插件里,如下配置证明有覆盖头部信息的问题
export default defineNuxtPlugin((nuxtApp) => {
if (process.server) {
const { collect } = setup(nuxtApp.vueApp);
nuxtApp.ssrContext!.renderMeta = () => {
return {
headTags: collect(), // 用于在head头部插入style标签,无css条件下会有白屏
};
};
}
});
但是在SSG模式下,头部信息正常,ssg插件如下:
import { setup } from "@css-render/vue3-ssr";
import type { UserModule } from './types'
export const install: UserModule = ({ app, isClient, head }) => {
if (!isClient && head) {
const { collect } = setup(app);
head.addHeadObjs(ref({
style: [
{
children: collect()
}
]
}))
}
}
临时结论:可能在nuxt3里需要一种add函数
It seems to be supported in the known webpack mode, but we only care about the Vite mode. we need help。
Mini DEOM: https://stackblitz.com/github/Baiyuetribe/nuxt3-naive-ui-starter
由于Nuxt3说明文档极简,渲染SEO应用实际上是固定输出到浏览器客户端,因此本地的路由router
全都不能使用,必须要转向window.location.href
。该问题被我折腾了好几天才想清楚,啊啊啊,尝鲜代价有多痛
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.