小编VKS*_*VKS的帖子

使用javascript进行SVG剪辑

我们正在尝试使用clippath来使用javascript进行折线.我们尝试编写一个可以正常工作的示例HTML代码:

<svg xmlns="http://www.w3.org/2000/svg" version="1.1" id="parent">
    <clippath id="cut-off-bottom">
        <rect x="0" y="0" width="200" height="100" />
    </clippath>
    <circle cx="100" cy="100" r="100" clip-path="url(#cut-off-bottom)" />
</svg>
Run Code Online (Sandbox Code Playgroud)

这绝对没问题.

但是当我们尝试使用javascript生成相同的代码时,它不起作用:

_svgNS = 'http://www.w3.org/2000/svg';
parent = document.getElementById('parent');

circle = document.createElementNS(_svgNS, 'circle');
circle.setAttributeNS(null, 'cx', '100');
circle.setAttributeNS(null, 'cy', '100');
circle.setAttributeNS(null, 'r', '100');

clippath = document.createElementNS(_svgNS, 'clippath');
clippath.setAttributeNS(null, 'id', 'clip');

r = document.createElementNS(_svgNS, 'rect');
r.setAttributeNS(null, 'x', '0');
r.setAttributeNS(null, 'y', '0');
r.setAttributeNS(null, 'width', '200');
r.setAttributeNS(null, 'height', '100');


clippath.appendChild(r);

circle.setAttributeNS(_svgNS, 'clip-path', 'url(#clip)');
parent.appendChild(clippath);
parent.appendChild(circle);
Run Code Online (Sandbox Code Playgroud)

任何人都可以帮助我们找到上述代码的问题...

提前致谢.

javascript html5 svg

10
推荐指数
1
解决办法
5683
查看次数

Grunt qunit失败了

我配置了我的qunit任务是如下咕噜声:

 // Unit Test Configuration
    qunit: {
        ac: {
            files: ['test/**/*.html']
        }
    }
    grunt.registerTask('ac', ['jshint:ac', 'qunit:ac']);
Run Code Online (Sandbox Code Playgroud)

jsHint运行正常.但随着qunit我得到错误:

运行"qunit:ac"(qunit)任务警告:不能使用'in'运算符来搜索'src'

gruntjs grunt-contrib-qunit

5
推荐指数
1
解决办法
1547
查看次数

我可以在单个Grunt文件中配置多个jsHint任务吗?

我有一个为2个不同模块配置的grunt文件.在一个任务中,我可以提供多个来源,一切正常.现在我的要求是为两个模块提供不同的选项 - 我希望两个模块都有不同的JsHint规则,我希望这两个项目都有单独的缩小文件和一个通用的缩小文件.

Gruntfile.js - >

jshint:{

  ac:{
      options: {

          laxcomma: true, // maybe we should turn this on? Why do we have these 
          curly: true,
          eqeqeq: true,
          immed: true,
          latedef: true,
          onevar: true
      },
      source: {
          src: ['module1/*.js']
      }
  },
  lib:{
      options: {
          laxcomma: true, // maybe we should turn this on? Why do we have these 
          curly: true,
          eqeqeq: true,
          immed: true,
          latedef: true
      },
      source: {
          src: ['module2/*.js']
      }
  }
Run Code Online (Sandbox Code Playgroud)

}

我看到了一些堆栈溢出问题,但我只能找到Grunt-hub作为一个选项,我需要创建2个单独的文件,然后是一个grunt hub文件.我不想这样做,请指导我如何进行?

gruntjs

4
推荐指数
1
解决办法
3277
查看次数

在gruntfile中的任务中添加任务

我有gruntfile如下:

       concat: {
        options: {
            banner: '<%= banner %>',
            stripBanners: true
        },
        one: {
            src: ['src/**/*.js'],
            dest: 'dist/<%= pkg.name %>_ac.js'
        },

        two: {
            src: ['/types/**/*.js'],
            dest: 'dist/<%= pkg.name %>_lib.js'
        },

        all: {
        }
    },.....  and so on
Run Code Online (Sandbox Code Playgroud)

现在,如果我注册任务,如:grunt.registerTask('basic',['concat:all']);

我希望一个和两个都跑.我该如何添加此选项

     all: {
          // what i need to add here to include one and two both?
     }
Run Code Online (Sandbox Code Playgroud)

gruntjs

0
推荐指数
1
解决办法
500
查看次数

标签 统计

gruntjs ×3

grunt-contrib-qunit ×1

html5 ×1

javascript ×1

svg ×1