Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
3.8k views
in Technique[技术] by (71.8m points)

wxss文件获取全局变量值?

想问一下wxss能不能支持获取全局变量,比如:

wxss文件中类bg中需要引入一个背景图,但是这个背景图是线上的,所以想通过统一的图片ip地址引入

如:

`.bg{
backage-img:url('全局变量'+ 'xxxxx')
}`


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

wxss不支持
backage-img:url(...),但是可以

  1. 使用内联base64代码的方式实现
  2. 自定义个一个bg-component组件使用<image src>引入这背景图,然后使用这个背景的组件包括在组件中就可以,<bg-componen>其它组件</bg-component>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...