Skip to content
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

Hello, 我遇到了一个问题 vite-plugin-uni-layouts 不生效 #5

Closed
sharebravery opened this issue Jun 29, 2023 · 5 comments
Closed

Comments

@sharebravery
Copy link

"@uni-helper/vite-plugin-uni-layouts": "^0.1.1",
"@uni-helper/vite-plugin-uni-pages": "^0.2.2",
"vue": "^3.3.4",
"vite": "4.1.4",
@Ares-Chang
Copy link
Owner

你好,你的 package version 与示例文件并没有不一样,效果参考 主页示例 web

如果你重装依赖并重启项目后依旧有问题,请提示一个 demo repo 否则我无法准确复现你的问题,感谢。

请提供最小重现

@sharebravery
Copy link
Author

sharebravery commented Jun 30, 2023

我刚才发现了问题 我在

<route lang="yaml">
name: Demo
layout: default
style:
  navigationBarTitleText: Demo
tabBar:
  iconPath: static/images/tabBar/demo.png
  selectedIconPath: static/images/tabBar/selectedDemo.png
</route> 

加入了基本信息之外的信息tabBar 导致它运行不正确 令我困惑的是即便我撤销了更改也不生效了 我去问一下这个库的吧

@Ares-Chang
Copy link
Owner

这个插件其实还没有热更新,你修改后需要重启项目.

你的 layout 没有正确加载,应该不是这个问题导致的,我按你説的修改了配置,但是依旧没有问题。

image
image

如果你想让我了解更多的话,请务必提供一个 demo repo ,或在线编辑器链接,因为我无法模拟出你遇见的问题,感谢。

@sharebravery
Copy link
Author

找到问题了 吐血! 居然是头部注释的问题!

<!--
 * @Description: 头部不能有这个注释。。。
 * @Author:
 * @Date: 2023-06-30 09:05:38
-->

我本来还以为是我加上对tabbar的处理造成的 一直找一直找 o(╥﹏╥)o

    UniPages({
      dir: 'src/pages',
      routeBlockLang: 'yaml',
      exclude: ['**/components/*.vue'],
      subPackages: [
        'src/pages-sub',
      ],
      onBeforeWriteFile(ctx) {
        type PageMeta = (PageMetaDatum & { name: string; tabBar?: { text?: string; iconPath: string; selectedIconPath: string } })

        const pageMetaData = ctx.pageMetaData as PageMeta[]

        ctx.pagesGlobConfig!.tabBar!.list = pageMetaData.flatMap(e => 'tabBar' in e
          ? {
              pagePath: e.path,
              text: e.tabBar?.text ? e.tabBar.text : e.style?.navigationBarTitleText,
              iconPath: e.tabBar!.iconPath,
              selectedIconPath: e.tabBar!.selectedIconPath,
            }
          : [])
      },
    }),

@Ares-Chang
Copy link
Owner

... 这种东西见仁见智,我是并不推荐文件头部注释的,没什么用,而且时间作者,你改代码也并一一定记得会改。

不如做好 git commit ,推荐在 VSCode 中安装个插件更实用。

GitLens

image

可以参考一下我的 use 里面用很多我觉得实用的插件。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants