如何在凉亭中使用jQuery UI? [英] How to use jquery ui with bower?

查看:185
本文介绍了如何在凉亭中使用jQuery UI?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试 yeoman 下端.

我使用以下命令创建了一个yeoman Web应用程序

I have created a yeoman webapp using the following command

yo webapp

我想使用 jqueryui ,所以我已经使用Bower安装了它:

I want to use jqueryui so I have installed it using bower:

bower install jquery-ui --save

这很好用,但是jQuery UI组件不包含带有所有"组件的javascript文件,它仅包含许多javascript文件,每个组件一个.

This works fine, but the jQuery UI component doesn't contain a javascript file with "all" the components, it just contains a lot of javascript files, one for each component.

我应该只包含所需的javascript文件吗?还是在使用jQuery UI之前我应该​​做其他事情?

Should I include only the javascript files that I need? Or should I do something else before using jQuery UI?

感谢您的提示!

推荐答案

bower.json(或component.json)的dependencies中将jquery-uijquery一起添加.

Added jquery-ui in dependencies of bower.json (or component.json) along with jquery.

{
  …,
  "dependencies": {
    "jquery": "~1.9.1",
    "jquery-ui": "~1.10.3",
    ...
  },
  …
}

安装它们:

bower install

然后,在main.js中添加到jqueryui的路径并要求它:

Then, added path to jqueryui In main.js and require it:

require.config({
  paths: {
    jquery: '../components/jquery/jquery',
    jqueryui: '../components/jquery-ui/ui/jquery-ui',
    …
  },
  shim: {
    jqueryui: 'jquery',
    …
  },
  …
});
require(['app', 'jquery', 'jqueryui', 'bootstrap'], function (app, $) {
  'use strict';
   ...
});

对我有用.

这篇关于如何在凉亭中使用jQuery UI?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆