gpt4 book ai didi

javascript - 如何让 Grunticon 'data-grunticon-embed' 选项嵌入工作

转载 作者:行者123 更新时间:2023-11-29 15:33:43 24 4
gpt4 key购买 nike

我在使用来自 grunticon 的 data-grunticon-embed 时遇到问题。 https://github.com/filamentgroup/grunticon

我已经尝试在本地和我的网络服务器上运行它,但在 Chrome 或 Safari 中似乎没有任何结果。

我的 Gruntfile.js

module.exports = function(grunt) {
// Project configuration.
grunt.initConfig({
grunticon: {
myIcons: {
files: [{
expand: true,
cwd: 'grunt/svgs',
src: ['*.svg', '*.png'],
dest: "grunt/output"
}],
options: {
loadersnippet: "grunticon.loader.js",
enhanceSVG: true,
}
}
}
});
grunt.loadNpmTasks('grunt-grunticon');
grunt.registerTask('default', ['grunticon:myIcons']);
};

在我的标题中我有

<script>
/* grunticon Stylesheet Loader | https://github.com/filamentgroup/grunticon | (c) 2012 Scott Jehl, Filament Group, Inc. | MIT license. */
window.grunticon=function(e){if(e&&3===e.length){var t=window,n=!(!t.document.createElementNS||!t.document.createElementNS("http://www.w3.org/2000/svg","svg").createSVGRect||!document.implementation.hasFeature("http://www.w3.org/TR/SVG11/feature#Image","1.1")||window.opera&&-1===navigator.userAgent.indexOf("Chrome")),o=function(o){var r=t.document.createElement("link"),a=t.document.getElementsByTagName("script")[0];r.rel="stylesheet",r.href=e[o&&n?0:o?1:2],a.parentNode.insertBefore(r,a)},r=new t.Image;r.onerror=function(){o(!1)},r.onload=function(){o(1===r.width&&1===r.height)},r.src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///ywAAAAAAQABAAACAUwAOw=="}};
grunticon(["<?php echo get_template_directory_uri(); ?>/grunt/output/icons.data.svg.css", "<?php echo get_template_directory_uri(); ?>/grunt/output/icons.data.png.css", "<?php echo get_template_directory_uri(); ?>/grunt/output/icons.fallback.css"], grunticon.svgLoadedCallback );
</script>
<noscript><link href="<?php echo get_template_directory_uri(); ?>/grunt/output/icons.fallback.css" rel="stylesheet"></noscript>

在我的页面上,我正在使用它,图标看起来很好,但没有嵌入 svg 数据。

<div class="icon-twitter" style="width: 50px; height: 50px; background-size:50%;" data-grunticon-embed></div></a>


更新:

对此仍然不满意。我现在在我的服务器上运行它 http://benjgorman.com/页脚/导航中的图标是 svg。我可以看出浏览器正在获取 SVG 数据,正如我在控制台中看到的那样,但它不是内嵌在页面上的,因此它无法设置样式。

Console information

Inspect element on same icon

最佳答案

事实证明,当我遵循过时的教程时,我使用了错误版本的 Grunticon。我的 package.json 现在看起来像下面需要修改的内容。之后一切正常。

{
"name": "my-grunticon-test",
"version": "0.1.0",
"dependencies": {
"grunt": "~0.4.4",
"grunt-grunticon": "~2.2.1"

}
}

关于javascript - 如何让 Grunticon 'data-grunticon-embed' 选项嵌入工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31842494/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com