JS中bootstrap和jquery引入

127 篇文章 2 订阅
111 篇文章 1 订阅

1.在网络的情况下,启动webstorm中的Terminal,输入(黑体字)

 

F:\A-H5-GP9\test>npm i bootstrap@3.3.5

npm WARN saveError ENOENT: no such file or directory, open 'F:\A-H5-GP9\test\package.json'

npm notice created a lockfile as package-lock.json. You should commit this file.

npm WARN enoent ENOENT: no such file or directory, open 'F:\A-H5-GP9\test\package.json'

npm WARN test No description

npm WARN test No repository field.

npm WARN test No README data

npm WARN test No license field.

 

+ bootstrap@3.3.5

added 1 package in 6.441s

 

F:\A-H5-GP9\test>npm i jquery

npm WARN saveError ENOENT: no such file or directory, open 'F:\A-H5-GP9\test\package.json'

npm WARN enoent ENOENT: no such file or directory, open 'F:\A-H5-GP9\test\package.json'

npm WARN test No description

npm WARN test No repository field.

npm WARN test No README data

npm WARN test No license field.

 

+ jquery@3.3.1

added 1 package in 4.051s

 

2.完成对bootstrapjquery的获取 上述

当我们输入上述两行后,会自动下载,然后记得相应的路径不要错误。

 

3.引入文件

 

<linkhref="node_modules/bootstrap/dist/css/bootstrap-theme.css"rel="stylesheet">

<scriptsrc="node_modules/jquery/dist/jquery.js"></script>

<scriptsrc="node_modules/bootstrap/dist/js/bootstrap.js"></script>

 

测试:

<!DOCTYPEhtml>

<htmllang="en">

<head>

<metacharset="UTF-8">

<title>Title</title>

<!--前期准备工作-->

<linkhref="node_modules/bootstrap/dist/css/bootstrap-theme.css"rel="stylesheet">

<scriptsrc="node_modules/jquery/dist/jquery.js"></script>

<scriptsrc="node_modules/bootstrap/dist/js/bootstrap.js"></script>

</head>

<body>

<buttonclass="btnbtn-default">XBL</button>

</body>

</html>

 

4.效果

 

  • 2
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Thymeleaf是一个模板引擎,它可以与BootstrapJQuery集成使用。下面是一些集成的步骤: 1. 引入BootstrapJQuery的CSS和JS文件 在HTML文件引入BootstrapJQuery的CSS和JS文件: ```html <!-- 引入 Bootstrap 的 CSS --> <link href="https://cdn.bootcss.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"> <!-- 引入 jQuery --> <script src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script> <!-- 引入 BootstrapJS 文件 --> <script src="https://cdn.bootcss.com/bootstrap/3.3.7/js/bootstrap.min.js"></script> ``` 2. 在Thymeleaf使用BootstrapJQuery的标记 在Thymeleaf的模板文件,可以使用BootstrapJQuery的标记来渲染页面: ```html <!DOCTYPE html> <html xmlns:th="http://www.thymeleaf.org"> <head> <meta charset="UTF-8"> <title>Thymeleaf Bootstrap jQuery Demo</title> <!-- 引入 Bootstrap 的 CSS --> <link href="https://cdn.bootcss.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"> <!-- 引入 jQuery --> <script src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script> <!-- 引入 BootstrapJS 文件 --> <script src="https://cdn.bootcss.com/bootstrap/3.3.7/js/bootstrap.min.js"></script> </head> <body> <div class="container"> <h1 th:text="${title}"></h1> <table class="table"> <thead> <tr> <th>Name</th> <th>Email</th> </tr> </thead> <tbody> <tr th:each="user : ${users}"> <td th:text="${user.name}"></td> <td th:text="${user.email}"></td> </tr> </tbody> </table> <button type="button" class="btn btn-primary">Save</button> </div> </body> </html> ``` 在上面的例子,使用了Bootstrap的表格和按钮,以及JQuery的循环。 3. 在Controller传递数据 在Controller,可以使用Thymeleaf的Model对象来传递数据: ```java @Controller public class UserController { @GetMapping("/") public String index(Model model) { List<User> users = new ArrayList<>(); users.add(new User("Alice", "alice@example.com")); users.add(new User("Bob", "bob@example.com")); model.addAttribute("title", "User List"); model.addAttribute("users", users); return "index"; } } ``` 在上面的例子,将用户列表传递给模板,以便在页面渲染。 这样,Thymeleaf、BootstrapJQuery就可以集成使用了。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值