我被要求为我们的离子项目修复工作.我必须用Rem单位替换所有像素单位,但我不想逐个文件来替换它们,而是我发现这看起来很像一个解决方案,但我几乎不知道我应该在哪里写这个任务和指令
Gulp任务:
gulp.task('build:rem', ['build:sass'], function() {
function replaceWith(match, p1, offset, string) {
return p1 / 16 + 'rem';
}
return gulp.src('./www/index.html')
.pipe(assets({js: false, css: true}))
.pipe(tap(function(file) {
file.contents = new Buffer(file.contents.toString().replace(/([\d.]+)\s*px/g, replaceWith));
}))
.pipe(gulp.dest('./www'));
});
Run Code Online (Sandbox Code Playgroud)
指令及其扩展:
(function() {
'use strict';
angular.module('App.core')
.directive('style', StyleDirective);
StyleDirective.$inject = ['$timeout'];
function StyleDirective($timeout) {
function pxToRem(el, at) {
if (el.attr('style')) {
at.$set('style', el.attr('style').replace(/([\d.]+)\s*px/g, function(match, p1, offset, value) {
return p1 / 16 + 'rem';
}));
}
}
return {
restrict: 'A',
compile: function(element, …Run Code Online (Sandbox Code Playgroud) 我被指派实施一些图表,并且老板要求我将图表的标题与图表分开,我试图将图表的区域从顶部稍微移开,但标题也随图表一起移动,如下所示:

我尝试使用:chartArea:{top:80}结果就是截图.我确定该物业只移动标题是另一个,但我还没找到它.顺便说一句,这是我的整个对象:
var columnChartProps = {
fontName: 'HelveticaNeueBC',
legend: {position: 'none'},
titleTextStyle: {fontSize: 18},
hAxis: {color: '#121b2d'},
vAxis: {
gridlines: {color: '#666666'}
},
width: 400,
height: 300,
backgroundColor: '#CBCBCB',
chartArea:{top:80, width:"80%"}
}
// VENCIMIENTOS:
var vencData = google.visualization.arrayToDataTable([
['equis', 'Vencimientos'],
['ENE', 7],
['FEB', 10],
['MAR', 5],
['ABR', 6],
['MAY', 10],
['JUN', 15]
]);
var vencOptions = {
colors:['#24375e','#2c4370','#324a7c','#38538a','#3e5b96','#4363a3'],
title: 'Vencimientos prox. 6 meses',
hAxis: {title: 'Meses'}
};
var vencimientos = new google.visualization.ColumnChart(document.getElementById('vencimientos'));
vencimientos.draw(vencData, jQuery.extend({},vencOptions,columnChartProps));
Run Code Online (Sandbox Code Playgroud)
提前致谢 :)