在蒸汽上使用Bootstrap

时间:2017-04-11 12:19:09

标签: swift bootstrap-4 vapor

我是网络开发的新手,无法找到明确的答案。

是否可以在Swapor 3的Vapor中使用Bootstrap?

1 个答案:

答案 0 :(得分:7)

是的,您可以使用Bootstrap。你会:

  • 将CDN链接添加到您的模板文件,即.leaf文件夹中的Resources/Views/个文件,或
  • 下载Bootstrap文件并将CSS,JS,字体等添加到Public/文件夹中,所有页面都可以访问该文件夹。

对于第一个建议,您可以将CDN链接添加到base.leaf,如下所示:

<!DOCTYPE html>
<html>
<head>
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css" integrity="sha384-rHyoN1iRsVXV4nD0JutlnGaslCJuC7uwjduW9SVrLvRYooPp2bWYgmgJQIXwl/Sp" crossorigin="anonymous">
    #import("head")
</head>
    <body>
        #import("body")
    </body>
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
</html>

对于第二个建议,您可以将文件放在此处:

enter image description here

然后访问这样的文件:

<!DOCTYPE html>
<html>
<head>
    <link rel="stylesheet" href="/styles/{CSS-FILE-NAME}">
    #import("head")
</head>
    <body>
        #import("body")
    </body>
    <script src="/{JS-FILE-NAME}"></script>
</html>