在less.css中创建和使用用户函数
Create and use user functions in lesscss
我的html:中有这个
<script type="text/javascript">
less = {
env: "development", // or "production"
async: false, // load imports async
fileAsync: false, // load imports async when in a page under
// a file protocol
poll: 1000, // when in watch mode, time in ms between polls
functions: {
returnCenter: function (value, context) {
return 'center';
}
}, // user functions, keyed by name
dumpLineNumbers: "comments", // or "mediaQuery" or "all"
relativeUrls: false,// whether to adjust url's to be relative
// if false, url's are already relative to the
// entry less file
rootpath: ":/a.com/"// a path to add on to the start of every url
//resource
};
</script>
<script src="less.js" type="text/javascript"></script>
那么在函数中,如何在less文件中创建和使用函数呢?
谢谢,祝你好运!
p.D.这个回收中心不起作用。带参数或不带参数。
出于某种原因,您应该用小写字母写函数名。您的函数也应该返回正确的类型。
尝试:
<script>
less = {
env: "development",
functions: {
returncenter: function(context, value) {
return new(less.tree.Anonymous)('center');
}
}
};
</script>
现在你可以使用以下较少的代码:
selector {
property: returncenter();
}
前面的Less代码将编译成以下CSS代码:
selector {
property: center;
}
另请注意:LessCSS的用户定义函数?
相关文章:
- poster typeerror用户不是函数
- 如何通过获取用户输入和使用按钮来运行JavaScript函数
- 如何在 Mozilla 插件中调用用户函数
- 每次用户键入时调用函数
- jquery返回ajax响应和用户定义的变量到函数
- 用户定义的函数在 Angular Cordova 中不起作用
- 为什么不'当用户输入空格或字符太多/不够时,此函数会发出window.alert
- 用户在noConflict mod中使用jQuery定义函数
- 当用户滚动到底部时,Ajax函数会多次触发
- html将输入传递给具有用户输入的函数
- 最佳实践:在网页对用户可见后调用.Net函数
- 如何使用用户定义的相等函数在Javascript中创建一组用户定义的对象
- 在jQuery中:如何在用户展开窗口时更新函数
- 当用户在输入上按下回车键时,我该如何调用函数
- 如何设置用户当前位置以初始化离子框架中的函数
- 如何在javascript中对用户函数进行自定义回调
- 在less.css中创建和使用用户函数
- 为什么人们要在jQuery对象中添加自己的自定义/用户函数
- 外部JS函数onload与用户函数onload冲突
- 是否可以传递'$(this)'到jQuery中的委托用户函数