-
Notifications
You must be signed in to change notification settings - Fork 12
feat: support nvue pages #41
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
fc80c34
feat: support nvue pages
3db2f0f
refactor: 整理 nvue 页面路径与相对路径工具
skiyee 439b000
fix(examples): 将示例组件标签改为 view
skiyee a50c6af
chore(examples): 补充 App 平台依赖与脚本
skiyee ba667fb
feat(examples): 增加 nvue 演示页面
skiyee e6a509c
test: 增加 examples nvue 转换校验
skiyee 9916d41
docs: 精简 README 中的 nvue 说明
skiyee File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,19 +1,19 @@ | ||
| <script setup lang="ts"> | ||
| import { ref } from 'vue' | ||
| import GlobalToast from './components/GlobalToast.vue' | ||
|
|
||
| const HelloVueRef = ref('Hello app.Ku.vue') | ||
|
|
||
| const exposeRef = ref('this is form app.Ku.vue') | ||
|
|
||
| defineExpose({ | ||
| exposeRef, | ||
| }) | ||
| </script> | ||
|
|
||
| <template> | ||
| <div>Hello AppKuVue</div> | ||
| <KuRootView /> | ||
| <div>{{ HelloVueRef }}</div> | ||
| <GlobalToast /> | ||
| </template> | ||
| <script setup lang="ts"> | ||
| import { ref } from 'vue' | ||
| import GlobalToast from './components/GlobalToast.vue' | ||
| const HelloVueRef = ref('Hello app.Ku.vue') | ||
| const exposeRef = ref('this is form app.Ku.vue') | ||
| defineExpose({ | ||
| exposeRef, | ||
| }) | ||
| </script> | ||
| <template> | ||
| <view>Hello AppKuVue</view> | ||
| <KuRootView /> | ||
| <view>{{ HelloVueRef }}</view> | ||
| <GlobalToast /> | ||
| </template> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,32 +1,32 @@ | ||
| <script setup lang="ts"> | ||
| import { useToast } from '@/composables/useToast' | ||
|
|
||
| const { globalToastState, hideToast } = useToast() | ||
| </script> | ||
|
|
||
| <template> | ||
| <div v-if="globalToastState" class="toast-wrapper" @click="hideToast"> | ||
| <div class="toast-box"> | ||
| welcome to use @uni-ku/root | ||
| </div> | ||
| </div> | ||
| </template> | ||
|
|
||
| <style scoped> | ||
| .toast-wrapper{ | ||
| position: fixed; | ||
| top: 0; | ||
| left: 0; | ||
| width: 100%; | ||
| height: 100%; | ||
| background-color: rgba(0, 0, 0, 0.5); | ||
| display: flex; | ||
| align-items: center; | ||
| justify-content: center; | ||
| } | ||
|
|
||
| .toast-box{ | ||
| background: white; | ||
| color: black; | ||
| } | ||
| </style> | ||
| <script setup lang="ts"> | ||
| import { useToast } from '@/composables/useToast' | ||
| const { globalToastState, hideToast } = useToast() | ||
| </script> | ||
| <template> | ||
| <view v-if="globalToastState" class="toast-wrapper" @click="hideToast"> | ||
| <view class="toast-box"> | ||
| welcome to use @uni-ku/root | ||
| </view> | ||
| </view> | ||
| </template> | ||
| <style scoped> | ||
| .toast-wrapper{ | ||
| position: fixed; | ||
| top: 0; | ||
| left: 0; | ||
| width: 100%; | ||
| height: 100%; | ||
| background-color: rgba(0, 0, 0, 0.5); | ||
| display: flex; | ||
| align-items: center; | ||
| justify-content: center; | ||
| } | ||
| .toast-box{ | ||
| background: white; | ||
| color: black; | ||
| } | ||
| </style> | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,6 @@ | ||
| <template> | ||
| <div> | ||
| <slot /> | ||
| Default Layout | ||
| </div> | ||
| </template> | ||
| <template> | ||
| <view> | ||
| <slot /> | ||
| Default Layout | ||
| </view> | ||
| </template> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| <script setup lang="ts"> | ||
| import { onMounted, ref } from 'vue' | ||
|
|
||
| const pageLabel = ref('Hello NVUE + UniKuRoot') | ||
| const uniKuRoot = ref() | ||
|
|
||
| onMounted(() => { | ||
| // eslint-disable-next-line no-console | ||
| console.log('[nvue-demo] exposeRef from KuRoot:', uniKuRoot.value?.exposeRef) | ||
| }) | ||
| </script> | ||
|
|
||
| <template root="uniKuRoot"> | ||
| <view class="page"> | ||
| <text class="title">{{ pageLabel }}</text> | ||
| <text class="hint">This page is .nvue and should be wrapped by local GlobalKuRoot.</text> | ||
| <text class="hint">Check console for KuRoot exposeRef after mount.</text> | ||
| </view> | ||
| </template> | ||
|
|
||
| <style> | ||
| .page { | ||
| flex: 1; | ||
| padding: 24px; | ||
| background-color: #f8f8f8; | ||
| } | ||
|
|
||
| .title { | ||
| font-size: 20px; | ||
| color: #111111; | ||
| margin-bottom: 12px; | ||
| } | ||
|
|
||
| .hint { | ||
| font-size: 14px; | ||
| color: #666666; | ||
| margin-bottom: 8px; | ||
| } | ||
| </style> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| <template root="kuRoot"> | ||
| <view class="page"> | ||
| <text class="title">{{ title }}</text> | ||
| <text class="hint">Options API nvue page with local GlobalKuRoot registration.</text> | ||
| </view> | ||
| </template> | ||
|
|
||
| <script> | ||
| export default { | ||
| data() { | ||
| return { | ||
| title: 'Hello NVUE Options API', | ||
| } | ||
| }, | ||
| } | ||
| </script> | ||
|
|
||
| <style> | ||
| .page { | ||
| flex: 1; | ||
| padding: 24px; | ||
| background-color: #ffffff; | ||
| } | ||
|
|
||
| .title { | ||
| font-size: 20px; | ||
| color: #111111; | ||
| margin-bottom: 12px; | ||
| } | ||
|
|
||
| .hint { | ||
| font-size: 14px; | ||
| color: #666666; | ||
| } | ||
| </style> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
Repository: uni-ku/root
Length of output: 458
🌐 Web query:
uniapp NVUE CSS width: 100% height: 100% unsupported percentage layout💡 Result:
In uni-app, nvue pages render using native components rather than a webview, which imposes specific limitations on CSS [1][2][3]. Percentage-based layout, such as width: 100% or height: 100%, is not supported in nvue [4][5][6][1]. This is because the underlying native layout engine only supports Flexbox [4][6], and percentage values are not valid units in this native environment [5][7]. To achieve full-width or full-height layouts in nvue, you should use the following alternatives: For full width: Use width: 750rpx [5][7]. In uni-app, 750rpx is defined as the total width of the screen [5]. For full height: Use flex: 1 on the container [5][7]. This instructs the element to occupy the available remaining space within its parent, effectively filling the container's height when the parent is also set up correctly or occupies the screen [5]. Summary of constraints: 1. Percentage units (%, vh, vw, rem) are not supported [5][7][1]. 2. CSS layout must be based on Flexbox [4][6]. 3. Only px (absolute pixels) and rpx (relative pixels) are supported for length units [5][1]. If you need to set a container to be full-screen, ensure that all parent elements also have their height managed (e.g., using flex: 1) to ensure the layout propagates correctly to the bottom of the screen [5].
Citations:
🏁 Script executed:
Repository: uni-ku/root
Length of output: 9233
Avoid percentage dimensions in the NVUE toast overlay.
NVUE does not support percentage layout units, so
width: 100%/height: 100%on the sharedGlobalToastwrapper may not cover the page reliably. Use anchor offsets or NVUE-supported dimensions here.Proposed fix
.toast-wrapper{ position: fixed; top: 0; left: 0; - width: 100%; - height: 100%; + right: 0; + bottom: 0; background-color: rgba(0, 0, 0, 0.5);📝 Committable suggestion
🤖 Prompt for AI Agents
Source: MCP tools