我正在试验 Dart,现在正在尝试使用 Bootstrap因为它的 CSS 框架。当我下载最新版本的 Bootstrap(目前为 3.0.3)时,它具有以下文件结构:
├── css
│ ├── bootstrap.css
│ ├── bootstrap.min.css
│ ├── bootstrap-theme.css
│ └── bootstrap-theme.min.css
├── fonts
│ ├── glyphicons-halflings-regular.eot
│ ├── glyphicons-halflings-regular.svg
│ ├── glyphicons-halflings-regular.ttf
│ └── glyphicons-halflings-regular.woff
└── js
├── bootstrap.js
└── bootstrap.min.js
(1) 我将所有这些文件放在哪里,以及如何从我的 Dart 源文件和 HTML 文件中访问它们? 例如,假设我想从 Dart 文件中动态更改 DOM,并将 Bootstrap 类添加到元素 - 这会是什么样子?如果我只是想给一个 HTML 元素一个 Bootstrap 类(在一个 .html 文件中),这会是什么样子?
我假设我可能需要一个具有如下包结构的 Dart 项目:
MyDartApp/
web/
myapp.dart
asset/
bootstrap/
css/
bootstrap.css
bootstrap.min.css
bootstrap-theme.css
bootstrap-them.min.css
fonts/
glyphicons-halflings-regular.eot
glyphicons-halflings-regular.svg
glyphicons-halflings-regular.ttf
glyphicons-halflings-regular.woff
js/
bootstrap.js
bootstrap.min.js
但是对 Dart 和 Bootstrap 的经验如此之少,不确定我是否遗漏了任何重要的东西。显然,我需要以
asset/
的方式打包 Bootstrap 文件。我的 Dart/HTML 文件中的 URL 可以在运行之前/之后访问它们 pub build
.(2) 另外,我可以使用
min
吗? - 每个 CSS/JS 文件的版本(bootstrap.min.js
而不是 bootstrap.js
等)?
最佳答案
asset/
文件夹来放置这些文件。但是编辑器中的内置服务器暂时不支持 Assets ,您必须使用 pub serve
.要访问它们,请使用 /assets/<pkg_name>/<path>
(见 How to refer to assets)。或者,您可以将这些文件放在 /lib/
下。并通过 packages/<pkg_name>/<path>
访问它们. 关于twitter-bootstrap - 使用 Dart 和 Bootstrap,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20746095/