【已解决】自定义组件为何不支持全局样式的直接使用?

小程序 文章 2022-04-22 21:20 314 0 全屏看文

AI助手支持GPT4.0

【已解决】自定义组件为何不支持全局样式的直接使用?[Solved] Why does the custom component not support the direct use of global styles?

【已解决】自定义组件为何不支持全局样式的直接使用?

问题:自定义组件,若不在组件样式文件中手动引入全局样式,渲染后的组件实例直接样式丢失。

// component.wxss@import "../../app.wxss" // 引入一个全局样式!!! OMG!这难道不是完全多余的操作吗?逻辑和使用体验,不论哪个角度似乎都不该是这样。


建议:直接使用,无需手动引入。


---------------------------------------

已解决:有相同疑惑的朋友及时补课【组件样式隔离https://developers.weixin.qq.com/miniprogram/dev/framework/custom-component/wxml-wxss.html#%E7%BB%84%E4%BB%B6%E6%A0%B7%E5%BC%8F%E9%9A%94%E7%A6%BB

Problem: for custom components, if the global style is not manually introduced into the component style file, the rendered component instance will lose the style directly// component. wxss@import ".. /.. / APP. Wxss" / / introduce a global style!!! OMG! Isn't this a completely redundant operation? Logic and use experience, no matter which angle, seem not to be like this. Suggestion: it can be used directly without manual introduction--------------------------------------- Solved: friends with the same doubts make up lessons in time [component style isolation] https://developers.weixin.qq.com/miniprogram/dev/framework/custom-component/wxml-wxss.html#%E7%BB%84%E4%BB%B6%E6%A0%B7%E5%BC%8F%E9%9A%94%E7%A6%BB

回答:

用爱发电:

支持的

Component({  options: {    styleIsolation: 'apply-shared'  }})// orComponent({  options: {    addGlobalClass: true  }})
从君华:感谢解答
从君华:感谢,是我文档没看透ORZ
广州齐博网络科技有限公司:感谢分享
何静涵:申请,恢复游戏

-EOF-

AI助手支持GPT4.0