0

我刚遇到Gumby 框架,我已经从他们的网站下载了 zip 文件。当我在网上查找一些“教程”时,我发现他们在谈论诸如 Bower 之类的工具。我真的无法理解所有这些,所以我暂时搁置了它。

我浏览了 zip 文件夹。我找到了各种 css、img、js 等文件夹。我找到了一些列出 UI 组件等的网页。现在我做了一个自己的网页,并使用了它的导航栏、div 元素等。我编辑了中间的 CSS 文件以适应我的段落,等等

但是当我在 Gumby Framwork 上寻求帮助时,我几乎总是会发现提到这个 Bower 工具。

有什么我做错了吗?我应该像现在这样继续使用 Gumby,还是应该真正研究一下这个工具?

4

1 回答 1

1

I did a bunch of these tutorials: http://webdesign.tutsplus.com/series/getting-to-know-gumby--webdesign-16738

You don't have to use Bower if you don't want to. Whatever Works™</p>

But it might help if you understood a bit more what Bower is and what it's doing exactly.

From the first sentence on their website, Bower is just a package manager for the web. If you've used npm install for Node, sudo apt-get install, Ruby Gems, etc. then you should be familiar with the general premise of package managers.

Bower links to repos that have a bower.json file in them and that have been published to Bower. Here's a search tool for them: http://bower.io/search/

Basically, when you do bower install foo it will find the foo package and clone the repo to a folder in your project called bower_components.

Why would we want to do this? Free updates! Easy versioning!

Say you want jQuery. You could go to jquery.com, click on the download link, right click the file, save as, go to your index.html file, add the script tag for it; or just link to a CDN (this is actually kinda preferable but let's pretend it's a bad idea this time, let's pretend we have a boss that really wants a local copy).

Okay... we can do it that way... or we cd ~/path/to/project then bower install jquery

Test it out with this code. Notice the bower_components/package_name/exact_file path that you should be using.

<html>
    <head>
        <title>foo</title>
    </head>
    <body>

        <button>Click me</button>

        <script src="bower_components/jquery/jquery.min.js"></script>
        <script>
            $(function() {
                $('button').click(function() {
                    alert('It works!');
                });
            });
        </script>
    </body>
</html>

Now check it out. Your boss just came in and wants you to switch to an old version of jQuery instead so you can support IE or something. Type bower info jquery to see what versions are available. Cool. 1.10.0 is what we want. Now type bower install jquery#1.10.0. Bam, you're using the right version.

The downside to using Bower is that it pulls in a lottttt of stuff you might not need/want. For instance, we're just using one file for the jQuery import, but now we have something like 10 extra files just sitting around.

The upsides are great though. It only takes a minute to learn how to use and then you'll be versioning/updating like a pro.

So, to answer your question, you can either keep using a web gui to download .zips and all that crap. Or you can up your game drastically in 10 minutes. I suggest the latter. =)

于 2014-02-06T06:55:54.437 回答