- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我开始在我的 Aurelia Web 项目中使用 JSPM,我想知道使用 import "<client side library>"
是否有任何后果或优势。 ?
我在 JS 类中看到过这样的客户端库代码:
import "jquery";
import "bootstrap/css/bootstrap.css!"
import "bootstrap";
export class App {
constructor {
}
}
问题:以这种方式导入它与传统的包含 <script>
相比有什么区别/优点/缺点?和 <link>
.html
中的标签文件?
<html>
<head>
<link rel="stylesheet" src="<bootstrap path>/bootstrap.css">
</head>
<body>
<script type="text/javascript" src="<bootstrap path>/bootstrap.js"></script>
</body>
</html>
我的试验和错误告诉我,通过使用 import
在特定的类/js 文件中,它将库限制为该特定的 View 文件,而不是全局可用。
最终,当您为生产构建这些项目时,这些库不需要存在于 index.html 中吗?
最佳答案
我的意见是:你应该使用 import
关键字,原因如下:
import
, 所以这可能会让他们感到困惑import
负责加载它,所以如果你只是添加一个脚本标签,你可能会添加一些 import
然后可能会重新声明一些功能。<script>
代码中的标签JSPM is awesome! It's a little different to this project though – it combines a repository with a package manager and a client-side module loader, as opposed to simply bundling modules. JSPM allows you to use any module format and even develop without a build step, so it's a great choice for creating applications. Rollup generates smaller bundles that don't use the complex SystemJS format, and so is a better choice for creating libraries. A future version of JSPM may use Rollup internally, so you'll get the best of both worlds.
Rollup 是使用 import
的另一个pro .它的作用是提取您使用的库并获取您需要的最少代码量,因此如果您只需要一些东西,比方说,jQuery,您不需要让您的访问者下载 50KB(或多少)现在?)。
您可以阅读有关 Rollup 的更多信息 here .
关于javascript - JSPM - 使用导入与使用脚本标签包含客户端库文件有什么优点/缺点吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34327133/
我正在使用 jspm 0.16.2。 我正在使用这个 test project 当我将 Transpiler 设置为 none 时:transpiler: "none" 我收到一个错误 XHR err
命令 jspm 安装将软件包更新到最新版本? 最佳答案 jspm install安装 package.json 中列出的最新版本的软件包,尊重其中定义的 semver 范围。安装后,确切的版本号(不是
我试图了解在使用 JSPM 安装模块后如何运行可执行文件.例如,如果我运行 jspm install gulp ,那么我希望能够运行以下命令: ./jspm_packages/npm/gulp\@3.
我在 https://github.com/jspm/jspm-cli/wiki/Getting-Started 中安装了 jspm . npm 安装 jspm -g。 它运行。 我称之为:jspm
最近我开始使用 aurelia-framework 并且到目前为止一直很好但是当我编辑 config.js 以添加一些我的文件时不是通过 jspm 安装的东西工作正常我导入我的脚本没有错误但是当我克隆
我对jspm比较陌生。我想知道什么时候运行有什么区别jspm install package和 npm install package .我知道有一个 jspm/registry 的查找。但是在设置
当我安装 css插件,使用以下命令: jspm install css 以下添加到我的 config.js 中: System.config({ "map": { "css": "gith
这篇文章是 stackoverflow 转贴 self 的问题 https://github.com/frankwallis/plugin-typescript/issues/64和 https://
我刚刚在 Mac OS 上使用 npm 全局安装了 jspm (sudo npm install jspm -g)。现在,当我运行 jspm init 时,我看到以下控制台输出: err (jspm)
1)它是克隆 repo 还是从版本中提取?据我所知,它是从发行版中提取的。 2) 这是否可以通过选项以与为特定版本指定 @version 相同的方式覆盖。即我想从发布分支中提取特定的 zip 或只是克
我试图让 JSPM/Karma/Babel/Jasmine 一起工作。但是在运行 karma start 时出现错误 15 04 2016 17:34:02.428:INFO [karma]: Kar
在过去的一个项目中,我将jspm的public baseURL指向了app文件夹。但是,在任何新项目中,当我运行 jspm init 时,它默认为 app 文件夹,但我不想要这个。 我尝试寻找相关文档
我正在迁移一个项目以使用 JSPM 和 SystemJS。在我的应用程序中,我重写 Backbone Marionette 渲染方法以使用 Mustache 模板: Marionette.Render
我在所有项目中都使用 SystemJs 和 JSPM,感觉太棒了。使用前端库变得前所未有的简单,使用 JSPM 我可以通过几个简单的步骤来完成: 命令行:jspm 安装角度 index.ts|js:i
我升级到 --latest 但由于兼容性问题想降级到特定版本。 最佳答案 像这样指定版本号即可。 npm install jspm@1.0.0 关于javascript - 如何降级/安装特定版本的
我开始在我的 Aurelia Web 项目中使用 JSPM,我想知道使用 import "" 是否有任何后果或优势。 ? 我在 JS 类中看到过这样的客户端库代码: import "jquery";
将用 TypeScript 编写的库转换为 ES5 的当前推荐做法是什么? JSPM 文档似乎是针对网络应用程序的(即 jspm bundle-sfx )。 我在 Google 上找到的所有文章似乎都
用于 React 和 JSPM 项目的最佳测试框架及其相关帮助程序库是什么?我正在寻找组合在一起的各种库,以及该库的具体特点是什么使其成为一个强大的工具集? (希望稍后合并 redux) 最佳答案 我
我是 jspm 的新手。我想在我的项目中使用 materialize-css 。我认为理想的使用方式是在使用 jspm (jspm install npm:materialize-css) 安装后使用
所以我做了: $ jspm install github:Eonasdan/bootstrap-datetimepicker $ jspm install npm:moment 然后在我的 js 文件
我是一名优秀的程序员,十分优秀!