Vue 学习笔记(3,免费Java高级工程师学习资源

不掉发的花花 2021-08-08 18:12:55
java 后端 程序员


==========================================================================

  1. 创建组件对象;

  2. 定义路由对象的规则;

  3. 将路由对象注册到 vue 实例;

  4. 在页面中显示路由的组件;

  5. 根据链接切换路由;


<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>路由的基本使用</title>
</head>
<body>
<div id="app">
<!--4、在页面中显示路由的组件-->
<router-view></router-view>
<!--5、根据链接切换路由组件-->
<a rel="nofollow" href="#/login">点我登录</a>
<a rel="nofollow" href="#/register">点我注册</a>
</div>
</body>
</html>
<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
<script src="https://unpkg.com/vue-router@3.3.4/dist/vue-router.js"></script>
<script> // 1、创建组件对象 const login = { template: "登录" }; const register = { template: "注册" }; // 2、创建路由对象 const router = new VueRouter({ routes: [ // 定义路由对象的规则 // path:设置路由的路径, component:路径对应的组件 {path: "/login", component: login}, {path: "/register", component: register} ] }); const app = new Vue({ el: "#app", data: {}, methods: {}, router: router // 3、在vue实例中注册路由对象 }); </script>

  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 19.
  • 20.
  • 21.
  • 22.
  • 23.
  • 24.
  • 25.
  • 26.
  • 27.
  • 28.
  • 29.
  • 30.
  • 31.
  • 32.
  • 33.
  • 34.
  • 35.
  • 36.
  • 37.
  • 38.
  • 39.
  • 40.
  • 41.
  • 42.
  • 43.
  • 44.
  • 45.
  • 46.
  • 47.
  • 48.
  • 49.
  • 50.
  • 51.
  • 52.
  • 53.
  • 54.
  • 55.
  • 56.
  • 57.
  • 58.
  • 59.
  • 60.
  • 61.
  • 62.
  • 63.
  • 64.
  • 65.
  • 66.
  • 67.
  • 68.
  • 69.
  • 70.
  • 71.
  • 72.
  • 73.
  • 74.
  • 75.
  • 76.
  • 77.
  • 78.
  • 79.
  • 80.
  • 81.
  • 82.
  • 83.

router-link 使用

=================================================================================

作用:在切换路由时可以自动给路由路径加入#不需要手动加入。

使用 a标签 切换路由: 需要在路径前面加 #


<a rel="nofollow" href="#/login">点我登录</a>
<a rel="nofollow" href="#/register">点我注册</a>

  • 1.
  • 2.
  • 3.
  • 4.
  • 5.

使用 router-link 切换路由:

  • to属性书写路由路径;tag属性将 router-link 渲染成指定的标签;

<router-link to="/login" tag="a">我要登录</router-link>
<router-link to="/register" tag="button">点我注册</router-link>

  • 1.
  • 2.
  • 3.
  • 4.
  • 5.

默认路由

=======================================================================

作用:用来在第一次进入界面是显示一个默认的组件;


const router = new VueRouter({
routes: [
// {path: "/", component: login},
{path: "/", redirect:"/login"}, // redirect:当访问的是默认路由"/"时, 跳转到指定的路由展示[推荐]
{path: "/login", component: login},
{path: "/register", component: register}
]
});

  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.

路由中参数的传递

===========================================================================

传统方式传递参数


  1. URL 中通过 ? 拼接参数:

<router-link to="/login?username=zhenyu&password=12345" tag="a">我要登陆</router-link>

  • 1.
  • 2.
  • 3.
  1. 在组件中获取参数:通过 this.$route.query.xxx 来获取参数;

const login = {
template: "用户登录",
data() {return{}},
methods: {},
created() {
console.log("name=" + this.$route.query.name + ", pwd=" + this.$route.query.pwd)
}
};

  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.

restful 方式传递参数


  1. 通过使用路径方式传递参数:

const router = new VueRouter({
routes: [
{path: "/register/:name/:pwd", component: register}
]
});

  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.

<router-link to=“/register/zhenyu/12345” tag=“a”>我要注册</router-link>


2. 在组件中获取参数:通过 `this.$route.params.xxx` 来获取参数;

  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.

const register = {

template: "用户注册",
data() {return{}},
methods: {},
created() {
console.log("name=" + this.$route.params.name + ", pwd=" + this.$route.params.pwd);
}

};


[](
)完整示例
-----------------------------------------------------------------------

  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.

<!DOCTYPE html>

<html lang=“en”>

<head>

<meta charset="UTF-8">
<title>路由中传递参数</title>

</head>

<body>

<div id=“app”>

<router-view></router-view>
<router-link to="/login?name=zhenyu&pwd=12345" tag="a">我要登陆</router-link>
<router-link to="/register/zhenyu/12345" tag="a">我要注册</router-link>

</div>

</body>

</html>

<script src=“ https://cdn.jsdelivr.net/npm/vue/dist/vue.js”></script>

<script src=“https://unpkg.com/vue-router@3.3.4/dist/vue-router.js”></script>

<script> const login = {

 template: "用户登录 {{this.$route.query.name}}",
data() {return{}},
methods: {},
created() {
console.log("name=" + this.$route.query.name + ", pwd=" + this.$route.query.pwd);
}
};
const register = {
template: "用户注册 {{this.$route.params.name}} ",
data() {return{}},
methods: {},
created() {
console.log("name=" + this.$route.params.name + ", pwd=" + this.$route.params.pwd);
}
};
const router = new VueRouter({
routes: [
{path: "/", redirect: "/login"},
{path: "/login", component: login},
{path: "/register/:name/:pwd", component: register}
]
});
const app = new Vue({
el: "#app",
data: {},
methods: {},
router // 注册路由
}); </script>

![在这里插入图片描述](https://s2.51cto.com/images/20210808/1628417085172249.jpg)
[](
)嵌套路由
=======================================================================
1. 声明最外层和内层组件对象;
2. 创建含有路由对象的路由对象(嵌套路由),通过 `chidren` 嵌套;
3. 注册与使用路由;

  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 19.
  • 20.
  • 21.
  • 22.

<!DOCTYPE html>

<html lang=“en”>

<head>

<meta charset="UTF-8">
<title>路由中传递参数</title>

</head>

<body>

<div id=“app”>

<router-link to="/product">商品管理</router-link>
<router-view></router-view>

</div>

<template id=“product”>

<div>
商品管理
<router-link to="/product/add">商品添加</router-link>
<router-link to="/product/edit">商品编辑</router-link>
<router-view></router-view>
</div>

</template>

</body>

</html>

<script src=“ https://cdn.jsdelivr.net/npm/vue/dist/vue.js”></script>

<script src=“https://unpkg.com/vue-router@3.3.4/dist/vue-router.js”></script>

<script> // 声明最外层和内层组件对象

const product = {
template: '#product'
};
const add = {
template: "<h4>商品添加</h4>"
};
const edit = {
template: "<h4>商品编辑</h4>"
};
// 创建含有路由对象的路由对象(嵌套路由), 通过children嵌套
const router = new VueRouter({
routes: [
{
path: "/product",
component: product,
children: [
{path: "add", component: add},
{path: "edit", component: edit},
]
},
]
});
const app = new Vue({
el: "#app",
data: {},
methods: {},
router // 注册路由
}); </script>

[](
)路由结合 SpringBoot 案例
=====================================================================================
[](
)后台控制器
------------------------------------------------------------------------
这是一个简单的演示性的小项目,后台控制器返回一串 Json 字符串。

  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 19.
  • 20.
  • 21.

@RestController

@RequestMapping(“user”)

@CrossOrigin

public class UserController {

@GetMapping("findAll")
public List<User> findAll() {
List<User> list = Arrays.asList(
new User("21", "zhenyu", 21, new Date()),
new User("22", "小三", 24, new Date()),
new User("23", "小明", 25, new Date())

总结

我个人认为,如果你想靠着背面试题来获得心仪的offer,用癞蛤蟆想吃天鹅肉形容完全不过分。想必大家能感受到面试越来越难,想找到心仪的工作也是越来越难,高薪工作羡慕不来,却又对自己目前的薪资不太满意,工作几年甚至连一个应届生的薪资都比不上,终究是错付了,错付了自己没有去提升技术。

这些面试题分享给大家的目的,其实是希望大家通过大厂面试题分析自己的技术栈,给自己梳理一个更加明确的学习方向,当你准备好去面试大厂,你心里有底,大概知道面试官会问多广,多深,避免面试的时候一问三不知。

大家可以把Java基础,JVM,并发编程,MySQL,Redis,Spring,Spring cloud等等做一个知识总结以及延伸,再去进行操作,不然光记是学不会的,这里我也提供一些脑图分享给大家:

希望你看完这篇文章后,不要犹豫,抓紧学习,复习知识,准备在明年的金三银四拿到心仪的offer,加油,打工人!

领取资料只需要点击这里即可免费获取全部资料!

版权声明
本文为[不掉发的花花]所创,转载请带上原文链接,感谢
https://blog.51cto.com/u_15300844/3313977

  1. HTML + CSS + JavaScript to achieve cool Fireworks (cloud like particle text 3D opening)
  2. HTML + CSS + JavaScript realizes 520 advertising love tree (including music), which is necessary for programmers to express themselves
  3. Solve the problem of Web front-end deployment server (it can be deployed online without a server)
  4. HTML + CSS + JS make wedding countdown web page template (520 / Tanabata Valentine's Day / programmer advertisement)
  5. What else can driverless minibus do besides "Park connection"?
  6. Cloud native leads the era of all cloud development
  7. NRM mirror source management tool
  8. Bring it to you, flex Jiugong
  9. Lolstyle UI component development practice (II) -- button group component
  10. Deconstruction assignment in ES6
  11. Luo 2 peerless Tang clan was officially launched. The official gave a key point, and the broadcast time was implied
  12. 20初识前端HTML(1)
  13. 当新零售遇上 Serverless
  14. 20 initial knowledge of front-end HTML (1)
  15. When new retail meets serverless
  16. [golang] - go into go language lesson 5 type conversion
  17. [golang] - go into go language lesson 6 conditional expression
  18. HTML5(八)——SVG 之 path 详解
  19. HTML5 (8) -- detailed explanation of SVG path
  20. 需要开通VIP以后页面内容才能复制怎么办?控制台禁用javascript即可
  21. Web前端|CSS入门教程(超详细的CSS使用讲解,适合前端初学者)
  22. 实践积累 —— 用Vue3简单写一个单行横向滚动组件
  23. Serverless 全能选手,再下一城
  24. What if you need to open a VIP to copy the page content? Just disable JavaScript on the console
  25. Web front end | CSS introductory tutorial (super detailed CSS explanation, suitable for front-end beginners)
  26. Practice accumulation - write a single line horizontal scroll component simply with vue3
  27. Dili Reba is thin again. She looks elegant and high in a strapless hollow skirt, and her "palm waist" is beautiful to a new height
  28. Serverless all-round player, next city
  29. The difference between MySQL semi synchronous replication and lossless semi synchronous replication
  30. Vue表单设计器的终极解决方案
  31. The ultimate solution for Vue form designer
  32. Nginx从理论到实践超详细笔记
  33. Yu Shuxin's red backless swimsuit is split to the waist and tail, with a concave convex figure and excessive color matching, and his face is white to dazzling
  34. Nginx ultra detailed notes from theory to practice
  35. 【动画消消乐|CSS】086.炫酷水波浪Loading过渡动画
  36. typecho全站启用https
  37. CCTV has another popular employee. The off-site interpretation is very professional, and the appearance ability is no less than that of Wang Bingbing
  38. [animation Xiaole | CSS] 086. Cool water wave loading transition animation
  39. Enable HTTPS in Typecho
  40. 50天用JavaScript完成50个web项目,我学到了什么?
  41. 根据JavaScript中原生的XMLHttpRequest实现jQuery的Ajax
  42. What have I learned from completing 50 web projects with JavaScript in 50 days?
  43. "My neighbor doesn't grow up" has hit the whole network. There are countless horse music circles, and actor Zhou Xiaochuan has successfully made a circle
  44. 根据JavaScript中原生的XMLHttpRequest实现jQuery的Ajax
  45. Implement the Ajax of jQuery according to the native XMLHttpRequest in JavaScript
  46. Implement the Ajax of jQuery according to the native XMLHttpRequest in JavaScript
  47. 30 + women still wear less T-shirts and jeans. If they wear them like stars, they will lose weight
  48. 数栈技术分享前端篇:TS,看你哪里逃~
  49. Several stack technology sharing front end: TS, see where you escape~
  50. 舍弃Kong和Nginx,Apache APISIX 在趣链科技 BaaS 平台的落地实践
  51. Abandon the landing practice of Kong and nginx, Apache apisik on the baas platform of fun chain technology
  52. 浪迹天涯king教你用elementui做复杂的表格,去处理报表数据(合并表头,合并表体行和列)
  53. 前端HTML两万字图文大总结,快来看看你会多少!【️熬夜整理&建议收藏️】
  54. Wandering around the world king teaches you to use elementui to make complex tables and process report data (merge header, merge table body rows and columns)
  55. 路由刷新数据丢失 - vuex数据读取的问题
  56. Front end HTML 20000 word graphic summary, come and see how much you can【 Stay up late to sort out & suggestions]
  57. Route refresh data loss - vuex data reading problem
  58. Systemctl系统启动Nginx服务脚本
  59. Systemctl system startup nginx service script
  60. sleepless