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

小程序 文章 2022-04-22 21:20 357 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


国内超级便宜服务器

摸鱼人热门新闻聚合

钻级赞助商 我要加入

开发者在线工具

第三方支付技术请加QQ群

相关文章
微信小程序,手机待机后,是否可以发送网络请求?
在微信环境中打开url地址的链接,二次分享时wxjssdk配置不起作用, 分享没有图文?
【急】【急】【急】微信授权登录!!!
我是女鞋生产工厂,想自己也卖,哪别人怎么知道你的店,进入你的小店呢?
微信开发者平台的管理员离职了联系不上如何修改管理员信息?
随便看看
教育科技公司申请微信支付被拒绝? 4098
微信公众号免300认证教程 5119
小程序已经上线,作为管理员无法在小程序数据助手查看数据? 4430
小程序广告组件通过审核,但是小程序内没有显示广告? 4402
企业微信通讯录账号被管理员误/恶意删除,怎么办? 8442
问题? 7660
如何快速搭建抽奖助手小程序(无需代码知识) 5227
许涛 大哥在吗, 要解冻小程序的时候提示信息主体不一致, 能帮忙看下吗? 6496
小程序搜一搜全称搜索不显示 麻烦解决一下!谢谢 5796
我的小程序广告收款主体是个体工商户,每个月邮寄两次发票很是麻烦,我年底的时候打包邮寄一次可以么? 5458