如何动态改变值 [英] how to change value dynamically variable

查看:82
本文介绍了如何动态改变值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何动态使用无点变量.我的意思是如何在无点文件中动态分配值.有什么办法吗?

how to use dynamically dotless variables. I mean how to assign value dynamically in dotless file. Is there any way?

style.less文件包含

style.less file contain

@url_image: 

#head{ background: url(@url_image) no-repeat left top white;}

如何在运行时分配值?

推荐答案

当您说在.less文件中动态更改时,我不确定为什么要只在更少的文件中进行更改.如果只是在.less文件中进行更改,则必须编译该文件才能将更改导航到style.min.css和style.css文件,而您无法通过编程方式进行更改.

When you say change dynamically in .less file, I am not sure why you wanna just change it in less file. If you just change it in .less file, you'll have to compile the file in order to navigative the change to style.min.css and style.css files, which you can't do programmatically.

这是您可以做的:

 $('#head').css('background-image', "url("new-source");

所以jquery/javascript是您最好的选择

So jquery/javascript is your best bet

这篇关于如何动态改变值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆