微信小程序中WebStorm的LESS怎么使用
发表于:2025-11-10 作者:千家信息网编辑
千家信息网最后更新 2025年11月10日,本文小编为大家详细介绍"微信小程序中WebStorm的LESS怎么使用",内容详细,步骤清晰,细节处理妥当,希望这篇"微信小程序中WebStorm的LESS怎么使用"文章能帮助大家解决疑惑,下面跟着小
千家信息网最后更新 2025年11月10日微信小程序中WebStorm的LESS怎么使用
本文小编为大家详细介绍"微信小程序中WebStorm的LESS怎么使用",内容详细,步骤清晰,细节处理妥当,希望这篇"微信小程序中WebStorm的LESS怎么使用"文章能帮助大家解决疑惑,下面跟着小编的思路慢慢深入,一起来学习新知识吧。
Less环境
Less需要nodejs的npm
nodejs的环境这里略了
自己百度
通过
npm install less -g
安装好 less
(没有用过的,可以理解为 maven的库, gradle库,pods的库)
WebStorm的Less使用
先关联对应的less
当然,对应的wxss文件,在webstorm中的显示,
WebStorm:遇到的问题
这里,只要创建less文件,就会自动生成对应的wxss文件了(当然,写好保存less文件,会自动刷新wxss文件,很方便吧)
直接wxss和 less的比较
我们先看下页面
页面很简单
就只有一个 sky 套用 3个cloud 类
view class="container">
再看看css
.sky { height: 480px; background: #007fd5; position: relative; overflow: hidden; animation: sky_background 50s ease-out infinite;}.sky .clouds_one { background: url("../../resources/cloud/cloud_one.png"); position: absolute; left: 0; top: 0; height: 100%; width: 300%; animation: cloud 50s linear infinite; transform: translate3d(0, 0, 0);}.sky .clouds_two { background: url("../../resources/cloud/cloud_two.png"); position: absolute; left: 0; top: 0; height: 100%; width: 300%; animation: cloud 75s linear infinite; transform: translate3d(0, 0, 0);}.sky .clouds_three { background: url("../../resources/cloud/cloud_three.png"); position: absolute; left: 0; top: 0; height: 100%; width: 300%; animation: cloud 120s linear infinite; transform: translate3d(0, 0, 0);}@keyframes cloud { 0% { left: 0; } 100% { left: -200%; }}我们发现有很多重复的地方
功能不难,但是占了70行,并且很难复用
修改的画,还要看里面的逻辑
修改也不方便
Less的使用
我们简单定义变量 和 方法以后
用less 大体是这样的
@dodo-out-height : 480px; //@dodo-out-height : 480rpx;@dodo-bg-sky : #007fd5;@dodo-img-url-clouds_one : "../../resources/cloud/cloud_one.png";@dodo-img-url-clouds_two : "../../resources/cloud/cloud_two.png";@dodo-img-url-clouds_three : "../../resources/cloud/cloud_three.png";.sky { height: @dodo-out-height; background: @dodo-bg-sky; position: relative; overflow: hidden; animation: sky_background 50s ease-out infinite;}.sky .clouds_one { .dodo_clouds(@url:@dodo-img-url-clouds_one, @time: 50s)}.sky .clouds_two { .dodo_clouds(@url:@dodo-img-url-clouds_two, @time: 75s)}.sky .clouds_three { .dodo_clouds(@url:@dodo-img-url-clouds_three, @time: 120s)}.dodo_clouds (@url: @dodo-img-url-clouds_one, @height: 100%, @width: 300%, @time: 100s){ background: url(@url); position: absolute; left: 0; top: 0; height: 100%; width: 300%; animation: cloud @time linear infinite; transform: translate3d(0, 0, 0);}@keyframes cloud { 0% { left: 0 } 100% { left: -200% }}保存后,
我们发现对应的wxss文件,也改变了,直接生成了可以读取的文件
和之前直接写的文件没有太大区别
也不会出现对应的变量和方法
.sky { height: 480px; background: #007fd5; position: relative; overflow: hidden; animation: sky_background 50s ease-out infinite;}.sky .clouds_one { background: url("../../resources/cloud/cloud_one.png"); position: absolute; left: 0; top: 0; height: 100%; width: 300%; animation: cloud 50s linear infinite; transform: translate3d(0, 0, 0);}.sky .clouds_two { background: url("../../resources/cloud/cloud_two.png"); position: absolute; left: 0; top: 0; height: 100%; width: 300%; animation: cloud 75s linear infinite; transform: translate3d(0, 0, 0);}.sky .clouds_three { background: url("../../resources/cloud/cloud_three.png"); position: absolute; left: 0; top: 0; height: 100%; width: 300%; animation: cloud 120s linear infinite; transform: translate3d(0, 0, 0);}@keyframes cloud { 0% { left: 0; } 100% { left: -200%; }}预览下:
读到这里,这篇"微信小程序中WebStorm的LESS怎么使用"文章已经介绍完毕,想要掌握这篇文章的知识点还需要大家自己动手实践使用过才能领会,如果想了解更多相关内容的文章,欢迎关注行业资讯频道。
文件
程序
文章
内容
变量
方法
环境
页面
生成
妥当
功能
只有
地方
思路
新知
更多
有用
步骤
知识
知识点
数据库的安全要保护哪些东西
数据库安全各自的含义是什么
生产安全数据库录入
数据库的安全性及管理
数据库安全策略包含哪些
海淀数据库安全审计系统
建立农村房屋安全信息数据库
易用的数据库客户端支持安全管理
连接数据库失败ssl安全错误
数据库的锁怎样保障安全
新吴区定制软件开发差异
挖矿代理服务器
青岛亿云网络技术
微信小程序数据库随机数据
二手戴尔服务器双内存8gb
长春云北软件开发公司怎么样
网络安全创新突破
部队手机网络安全保密教育新闻
我的世界服务器神秘箱子钥匙
嵌入式的软件开发英语要好吗
数据库触发器的特征
语音聊天软件开发哪家产品较好
微信显示服务器断开
公安网络安全标准
核对档案数据库文件是什么工作
网络安全考研女生如何
公安网络安全执法资料汇
软件开发i项目沟通
河北威力软件开发调试
数据库文档两种类型是
服务器数据如何快速异地备份
数据库技术及应用电子教材
网络安全法关于转帖
宝塔建立网站数据库
小学生网络安全防控手抄报
如何通过病毒加密数据库
数据库安全审计与防护白皮书
艾尔维斯数据库
网络安全考研女生如何
网络技术简历范文