替换手写笔中的功能
replacing function in stylus
我有带有该代码的手写笔文件:
body
background url('/templates/main/img/sprites/ico-soc.png') 100px 100px no-repeat
我需要函数(mixin)background
它将从图像的引用中删除"/模板/主/"
body
background url('img/sprites/ico-soc.png') 100px 100px no-repeat
请帮助我)我想也许我走错了方向,有一个简单的方法可以解决问题。 请注意,我需要该函数。不要为目录创建变量!
这就是我正在做的
我做了功能
background()
background arguments
然后我尝试通过两种方式解决问题1)我试图找到一个替代功能。但失败了。然后我尝试使用文档的决定(函数替换)。但它不适合我的情况。http://learnboost.github.io/stylus/docs/bifs.html#add-propertyname-expr
2)我通过函数use(path)(http://learnboost.github.io/stylus/docs/bifs.html#usepath)在js上编写了我的函数。但是我遇到了一个问题,进入js函数的值不正确。有额外的空间。
风格.风格
use("add.js")
background()
background arguments
body
background url('img/sprites/ico-soc.png') 100px 100px no-repeat
添加.js
var plugin = function(){
return function(style){
style.define('add', function(a) {
console.log(typeof a);
console.log(a);
});
};
};
module.exports = plugin;
您可以使用 current-property
重新定义url
函数并检查它是否从 background
调用。例如:
url(str)
if current-property && current-property[0] == 'background'
str = replace('/templates/main/', '', str)
return unquote('url(' + str + ')')
body
background: url('/templates/main/img/sprites/ico-soc.png') 100px 100px no-repeat
编译为:
body {
background: url(img/sprites/ico-soc.png) 100px 100px no-repeat;
}
相关文章:
- 用玉石编写书法和手写笔
- SVG手写字母绘图动画
- 手写笔 (CSS) 的客户端使用
- 替换手写笔中的功能
- express.js - 使用手写笔作为中间件或构建它
- 从 git 存储库构建手写笔
- 咕噜咕噜的手表和手写笔
- 在res.render()之后,手写笔没有应用于我的玉文件
- 卡住了写一点折扣功能
- 是否可以在HTML5网页上接受手写笔输入
- 从手写JavaScript调用GWT方法
- 从GWT上的手写JS中获取Java方法返回值
- 使用css2stylus后,手写笔文件无法加载资源错误
- 如何使用Bootstrap手写笔与requireJS
- 在安装了Opera Mini的功能手机上,可以在不使用javascript的情况下选择要上传的文件来触发UI更改
- 没有手写JavaScript的AJAX web应用程序
- 使用JSNI从手写的Javascript调用JAVA方法
- 将JSON对象从手写javascript发送到GWT服务器端
- 文档.写,返回功能
- 在手写笔和节点中使用本地图像是否可行.js和快速