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

PageMeta 编译问题 #6092

Closed
baranwang opened this issue Apr 24, 2020 · 19 comments · Fixed by #14761 or #14811
Closed

PageMeta 编译问题 #6092

baranwang opened this issue Apr 24, 2020 · 19 comments · Fixed by #14761 or #14811
Assignees
Labels
enhancement New feature or request T-weapp Target - 编译到微信小程序
Milestone

Comments

@baranwang
Copy link
Contributor

问题描述

使用 PageMeta 编译后会在页面 json 中引入

{"usingComponents":{"page-meta":"@tarojs/components","navigation-bar":"@tarojs/components"}}

且未将 page-meta 编译至根节点

复现步骤

引入 PageMeta, NavigationBar

期望行为

json 中不引入,且编译至 wxml 根节点(因文档指出只能是页面内的第一个节点)

报错信息

["usingComponents"]["page-meta"]: "@tarojs/components" 未找到

系统信息

👽 Taro v2.1.5

Taro CLI 2.1.5 environment info:
System:
OS: macOS 10.15.4
Shell: 5.7.1 - /bin/zsh
Binaries:
Node: 13.13.0 - /usr/local/bin/node
Yarn: 1.22.4 - /usr/local/bin/yarn
npm: 6.14.4 - /usr/local/bin/npm
npmPackages:
@tarojs/components: 2.1.5 => 2.1.5
@tarojs/components-qa: 2.1.5 => 2.1.5
@tarojs/mini-runner: 2.1.5 => 2.1.5
@tarojs/mobx: 2.1.5 => 2.1.5
@tarojs/mobx-h5: 2.1.5 => 2.1.5
@tarojs/router: 2.1.5 => 2.1.5
@tarojs/taro: 2.1.5 => 2.1.5
@tarojs/taro-alipay: 2.1.5 => 2.1.5
@tarojs/taro-h5: 2.1.5 => 2.1.5
@tarojs/taro-qq: 2.1.5 => 2.1.5
@tarojs/taro-quickapp: 2.1.5 => 2.1.5
@tarojs/taro-swan: 2.1.5 => 2.1.5
@tarojs/taro-tt: 2.1.5 => 2.1.5
@tarojs/taro-weapp: 2.1.5 => 2.1.5
@tarojs/webpack-runner: 2.1.5 => 2.1.5
eslint-config-taro: 2.1.5 => 2.1.5
eslint-plugin-taro: 2.1.5 => 2.1.5
nerv-devtools: ^1.5.6 => 1.5.6
nervjs: ^1.5.6 => 1.5.6

@taro-bot
Copy link

taro-bot bot commented Apr 24, 2020

CC @Chen-jj

@taro-bot
Copy link

taro-bot bot commented Apr 24, 2020

欢迎提交 Issue~

如果你提交的是 bug 报告,请务必遵循 Issue 模板的规范,尽量用简洁的语言描述你的问题,最好能提供一个稳定简单的复现。🙏🙏🙏

如果你的信息提供过于模糊或不足,或者已经其他 issue 已经存在相关内容,你的 issue 有可能会被关闭。

Good luck and happy coding~

@luckyadam
Copy link
Member

luckyadam commented Apr 28, 2020

这个特性还未支持,不过看文档上也没有说要在 usingComponents 里配置 page-meta
https://developers.weixin.qq.com/miniprogram/dev/component/page-meta.html

@luckyadam luckyadam added the enhancement New feature or request label Apr 28, 2020
@Chen-jj Chen-jj modified the milestone: 3.0.9 Sep 1, 2020
@Chen-jj
Copy link
Contributor

Chen-jj commented Sep 3, 2020

PageMeta 需要是页面的第一个节点,不能放在 template 里,和现有 Taro3 的渲染机制有点冲突,暂时不支持了,之后再想想处理办法。

@Chen-jj Chen-jj added T-weapp Target - 编译到微信小程序 and removed 微信小程序 labels Sep 3, 2020
@iivu
Copy link

iivu commented Oct 2, 2020

PageMeta 需要是页面的第一个节点,不能放在 template 里,和现有 Taro3 的渲染机制有点冲突,暂时不支持了,之后再想想处理办法。

v1v2可以支持一下吗
@Chen-jj

@qianlongdoit
Copy link

@Chen-jj Taro v3版本现在支持吗,我试了一下,发现好像没效果

@linhaobin
Copy link
Contributor

@Chen-jj 这个有计划支持吗?现在有一个需求是希望能修改 root-font-size 来控制 rem

@Chen-jj
Copy link
Contributor

Chen-jj commented Dec 13, 2021

可以选择继承 @tarojs/plugin-platform-weapp,编写自定义的端平台插件,修改页面模板生成的部分。

例如:

// dist/index/index.wxml
<import src="../../base.wxml"/>

<page-meta root-font-size="{{rootFontSize}}">
  <template is="taro_tmpl" data="{{root:root}}" />
</page-meta>

如果还需要设置 data,可以使用 const page = Taro.getCurrentinstance().page 获取当前页面实例。然后再调用 setData:

page.setData({...})

@Chen-jj Chen-jj added this to the 3.4.0 milestone Dec 13, 2021
@jhxxs
Copy link

jhxxs commented Dec 14, 2021

可以选择继承 @tarojs/plugin-platform-weapp,编写自定义的端平台插件,修改页面模板生成的部分。

例如:

// dist/index/index.wxml
<import src="../../base.wxml"/>

<page-meta root-font-size="{{rootFontSize}}">
  <template is="taro_tmpl" data="{{root:root}}" />
</page-meta>

如果还需要设置 data,可以使用 const page = Taro.getCurrentinstance().page 获取当前页面实例。然后再调用 setData:

page.setData({...})

请问这个在react中要怎么实现?

@baranwang
Copy link
Contributor Author

可以选择继承 @tarojs/plugin-platform-weapp,编写自定义的端平台插件,修改页面模板生成的部分。
例如:

// dist/index/index.wxml
<import src="../../base.wxml"/>

<page-meta root-font-size="{{rootFontSize}}">
  <template is="taro_tmpl" data="{{root:root}}" />
</page-meta>

如果还需要设置 data,可以使用 const page = Taro.getCurrentinstance().page 获取当前页面实例。然后再调用 setData:

page.setData({...})

请问这个在react中要怎么实现?

还没看具体实现,不过这和框架没什么关系吧,react 中在useEffectsetData 不就行了

baranwang added a commit to baranwang/taro that referenced this issue Dec 14, 2021
NervJS#6092 继承 `@tarojs/plugin-platform-weapp` 可能需要 `src` 目录中的文件,`dist` 中 `component` 的定义为 `dist/index.js` 的内部定义,无法复用。
@baranwang baranwang reopened this Dec 14, 2021
@baranwang
Copy link
Contributor Author

baranwang commented Dec 14, 2021

https://github.com/baranwang/tarojs-plugin-platform-miniprogram 继承 @tarojs/plugin-platform-weapp 做了处理,并封装了 React 组件

cc @Chen-jj

@Chen-jj
Copy link
Contributor

Chen-jj commented Dec 14, 2021

https://github.com/baranwang/tarojs-plugin-platform-miniprogram 继承 @tarojs/plugin-platform-weapp 做了处理,并封装了 React 组件

cc @Chen-jj

老哥稳!如果能配置筛选需要添加的 prefix、suffix 就更好了

@baranwang
Copy link
Contributor Author

https://github.com/baranwang/tarojs-plugin-platform-miniprogram 继承 @tarojs/plugin-platform-weapp 做了处理,并封装了 React 组件
cc @Chen-jj

老哥稳!如果能配置筛选需要添加的 prefix、suffix 就更好了

更新了一个版本,增加 include 和 exclude 配置

@Chen-jj
Copy link
Contributor

Chen-jj commented Dec 17, 2021

已在文档标注暂时使用插件去支持:https://docs.taro.zone/docs/next/components/page-meta

希望 @baranwang 老哥有空可以把这个特性提交 PR 合到 Taro 主干的~

@slogeor
Copy link

slogeor commented Feb 25, 2022

https://github.com/baranwang/tarojs-plugin-platform-miniprogram 继承 @tarojs/plugin-platform-weapp 做了处理,并封装了 React 组件
cc @Chen-jj

老哥稳!如果能配置筛选需要添加的 prefix、suffix 就更好了

更新了一个版本,增加 include 和 exclude 配置

老哥, 我这还是不生效

@18601673727
Copy link

到现在<page-meta>还是一个不能在taro中使用的功能 希望重视一下

@Chen-jj
Copy link
Contributor

Chen-jj commented Nov 2, 2023

Taro v3.6.19开始支持

Chen-jj added a commit that referenced this issue Nov 3, 2023
* feat(weapp/alipay): 支持使用 PageMeta 和 NavigationBar 组件,fix #6092

* docs: 补充 PageMeta 和 NavigationBar 的文档

* fix(weapp/alipay): 删除在 base.xml 里的 page-meta, navigation-bar 模板

* fix: ci

* fix: ci
@sumail43db
Copy link

Taro v3.6.19开始支持

3.6.19什么时候release呢?

@LingF
Copy link

LingF commented Jan 9, 2024

支付宝小程序还是不行

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request T-weapp Target - 编译到微信小程序
Projects
None yet