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

针对 skyline 渲染器的部分调整 #13587

Closed
yfme01 opened this issue Apr 5, 2023 · 2 comments · Fixed by #13688
Closed

针对 skyline 渲染器的部分调整 #13587

yfme01 opened this issue Apr 5, 2023 · 2 comments · Fixed by #13688
Assignees
Labels
enhancement New feature or request good first issue Good for newcomers T-weapp Target - 编译到微信小程序

Comments

@yfme01
Copy link

yfme01 commented Apr 5, 2023

这个特性解决了什么问题?

  • 编译后的 app.wxss 中引用 common.wxss 在内容之后,skyline 只允许引用在文件最前面,但阅读过之前的文档,为了避免样式覆盖,只能将 common.wxss 放在后面

  • 还需要一个可以判断渲染器是 skyline 还是 webview 的 hook

这个 API 长什么样?

  • 可选的将 common.wxss 放在 app.wxss 前面,或可以在在引用 common.wxss 后方定义样式
  • useRenderer 返回 页面节点的 this.renderer
@ZakaryCode ZakaryCode added enhancement New feature or request T-weapp Target - 编译到微信小程序 labels Apr 6, 2023
@Chen-jj Chen-jj added the good first issue Good for newcomers label Apr 14, 2023
@Chen-jj
Copy link
Contributor

Chen-jj commented Apr 14, 2023

1 是老问题了,应该把 app 样式也抽取到独立的文件中进行引用,就能解决 app.css 的引用顺序问题:

@import './app-core.css';
@import './common.css';
  1. @AdvancedCat 鑫哥考虑看看是提供 Taro API 还是 hooks 的方式,如果是 hooks 可能也得考虑 Vue3.

@AdvancedCat
Copy link
Member

简单看了一下,在 weapp 插件中新增一个 Taro API :

  • Taro hooks 目前主要是副作用 hook 为主(useRouter 是例外),而应用参数一般是通过平台提供 api 来获得,不太适合;
  • 在插件@tarojs/plugin-platform-weapp 中新增一个 Taro.getRenderer(),获得当前页面的渲染器类型,这样不用区分技术栈;

根据 微信文档 描述,可通过 this.renderer 获取到渲染器类型,目前可以使用如下方法来获得:

import { getCurrentInstance } from '@tarojs/runtime'

// 获得 this.renderer
getCurrentInstance().page.renderer

React & Vue 均可用。

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

Successfully merging a pull request may close this issue.

4 participants