Vue learning notes (2, Java programming video tutorial)

Flowers without hair loss 2021-08-08 18:14:06
vue learning notes java programming


</head>

<body>

<div id=“app”>

<span id="sp"> {{ msg }} </span>
<input type="button" value=" change data Value " @click="changeData">

</div>

<!-- introduce Vue -->

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

<script> const app = new Vue({

 el: "#app",
data: {
msg: "hello Vue.js!",
},
methods: {
changeData() {
// this.msg = "Vue.js niubility!";
this.msg = Math.random();
}
},
// ==================== Initialization phase ====================
// 1. The first function in the life cycle , When the function is executed Vue The instance only completes the binding of its own events and the initialization of the life cycle function ,Vue There is no in the instance Data el methods Related properties
beforeCreate() {
console.log("beforeCreate: " + this.msg);
},
// 2. The second function in the life cycle , When the function is executed Vue The instance has been initialized data Properties and methods The related methods in this paper are as follows
created() {
console.log("created:" + this.msg);
},
// 3. The third function in the lifecycle , When the function is executed Vue take El The scope specified in is compiled as a template
beforeMount() {
console.log("beforeMount: " + document.getElementById("sp").innerText);
},
// 4. The fourth function in the life cycle , During the execution of this function , The data has been rendered into the interface and the page has been updated
mounted() {
console.log("Mounted: " + document.getElementById("sp").innerText);
},
// ==================== Operation phase ====================
// 5. The fifth function in the life cycle , The function is data Execute when the data in changes When this event is executed, it is just Vue In the example data The data change page still shows the original data
beforeUpdate() {
console.log("beforeUpdate-vue: " + this.msg);
console.log("beforeUpdate-dom: " + document.getElementById("sp").innerText);
},
// 6. The sixth function in the life cycle , When this function executes data Data changes in , The data in the page has also changed The data in the page has been and data The data in the are consistent
updated() {
console.log("updated-vue: " + this.msg);
console.log("updated-dom: " + document.getElementById("sp").innerText);
},
// ==================== Destruction phase ====================
// 7. The seventh function of the life cycle , When this function executes ,Vue All data in methods componet Not destroyed
beforeDestory() { },
// 8. The eighth function of the life cycle , When this function executes ,Vue The instance is completely destroyed
destoryed() { }
}); </script>

</body>

</html>


![ Insert picture description here ](https://s2.51cto.com/images/20210808/1628416908531743.jpg)
[](
)Vue Middle component (Component)
=====================================================================================
** Function of components **: To reduce Vue Amount of code in the instance object , Use... In the future Vue Development process , The page can be divided into different components according to different business functions , Then multiple components complete the layout of the whole page , Easy to use in the future Vue Page management during development , Convenient for developers to maintain .
[](
) Development of global components
--------------------------------------------------------------------------
Global components registered with Vue example , It can be done anywhere Vue Use the component within the scope of the instance .
Development of global components :

  • 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.

<!DOCTYPE html>

<html>

<head>

<meta charset=‘utf-8’>

<title> Development of global components </title>

</head>

<body>

<div id=“app”>

<!-- Use global components -->
<login></login>
<!-- Using local components -->
<user-login></user-login>

</div>

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

<script> // Develop global components

// Parameters 1: Component name
// Parameters 2: Component configuration object template: Used to write components html Code ( Be careful : stay template A container must exist in the )
Vue.component('login', {
template : '<div> The user login </div>'
});
// Components of hump nomenclature will be specially treated , userLogin It must be written as user-login
Vue.component('userLogin', {
template : '<div><input type="button" value=" Sign in "></div>'
});
const app = new Vue({
el: "#app",
data: {},
methods: {},
}); </script>

</body>

</html>


![ Insert picture description here ](https://s2.51cto.com/images/20210808/1628416908113583.jpg)
[](
) Development of local components
--------------------------------------------------------------------------
By registering the component with the corresponding Vue One in the instance `components` Property to complete component registration , This way won't be right Vue Instances cause accumulation .
The first development method :

  • 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>

<head>

<meta charset=‘utf-8’>

<title> Development of local components </title>

</head>

<body>

<div id=“app”>

<login></login>
<login></login>
<login></login>

</div>

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

<script> // Define variables to save template configuration objects

const login = {
template: '<div><h2> The user login </h2></div>'
};
const app = new Vue({
el: "#app",
data: {},
methods: {},
components: { // Local components
login: login // Register local components
}
}); </script>

</body>

</html>


The second development mode :

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

<!DOCTYPE html>

<html lang=“en” xmlns:v-on=“ http://www.w3.org/1999/xhtml”>

<head>

<meta charset=“UTF-8”>

<title> Development of local components 2</title>

</head>

<body>

<div id=“app”>

<login></login>
<login></login>
<login></login>

</div>

<!– Declare local component templates template label Be careful : stay Vue Instance out of scope declaration –>

<template id=“loginTemplate”>

<h2> The user login </h2>

</template>

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

<script> // Define variables to save template configuration objects

const login = { // Specific local component name
template: '#loginTemplate' // Definition template Label selector is OK
};
const app = new Vue({
el: "#app",
data: {},
methods: {},
components: { // Local components
login: login // Register local components
}
}); </script>

</body>

</html>


![ Insert picture description here ](https://s2.51cto.com/images/20210808/1628416908430469.jpg)
[](
) In the component props Use
================================================================================
`props` It is used to transfer corresponding static data or dynamic data to components ;
[](
) Declare static data on the component and pass it to the component
------------------------------------------------------------------------------------

  • 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.

<!DOCTYPE html>

<html lang=“en” xmlns:v-on=“ http://www.w3.org/1999/xhtml”>

<head>

<meta charset=“UTF-8”>

<title> Use... In local components props Receive static data </title>

</head>

<body>

<div id=“app”>

<!-- Use components , Static data transfer through components -->
<login user-name="zhenyu" age="20"></login>

</div>

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

<script> // Declare a component template configuration object

let login = {
template: '<div><h2> welcome : {{ userName }} Age : {{ age }}</h2></div>',
props: ['userName', 'age'] // props: It is used to receive the data passed through the component tag when using the component
}
const app = new Vue({
el: "#app",
data: {},
methods: {},
components: {
login // Component registration
}
}); </script>

</body>

</html>


![ Insert picture description here ](https://s2.51cto.com/images/20210808/1628416909341667.jpg)
[](
) Declare dynamic data on the component and pass it to the component
------------------------------------------------------------------------------------

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

<!DOCTYPE html>

<html lang=“en” xmlns:v-on=“ http://www.w3.org/1999/xhtml”>

<head>

<meta charset=“UTF-8”>

<title> Use... In local components prop Receive dynamic data </title>

</head>

<body>

<div id=“app”>

<!-- Use components to receive Vue Dynamic data in the instance -->
<!-- Use v-bind Form to bind data to Vue In the example data attribute , data Property changes , The internal data of the component changes accordingly -->
<login v-bind:name="username" :age="userage"></login>

</div>

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

<script> const login = {

 template: '<div><h2> welcome : {{ name }} Age : {{ age }}</h2></div>',
props: ['name', 'age']
}
const app = new Vue({
el: "#app",
data: {
username: "zhenyu",
userage: 25
},
methods: {},
components: {
login // Certified components
}
}); </script>

</body>

</html>


![ Insert picture description here ](https://s2.51cto.com/images/20210808/1628416909930747.jpg)
[](
)props One way data flow of
-------------------------------------------------------------------------------
be-all props Both make their father and son props There is a ** One way downlink binding **: Parent props The update flows down to the child component , But not the other way around . This prevents accidental changes to the state of the parent component from the child component , This causes your application's data flow to be difficult to understand .
# ** Reader benefits **
** Because the length is too long , Don't show all the interview questions , Interested partners **
** Focus on + After likes , Click here to get the complete interview questions ( With answers )!**
![35K Successful entry : Interview with ant financial Java Back end experience !「 Including interview questions + answer 」](https://s2.51cto.com/images/20210808/1628416909345884.jpg)
![35K Successful entry : Interview with ant financial Java Back end experience !「 Including interview questions + answer 」](https://s2.51cto.com/images/20210808/1628416910985723.jpg)
![35K Successful entry : Interview with ant financial Java Back end experience !「 Including interview questions + answer 」](https://s2.51cto.com/images/20210808/1628416910409141.jpg)
** More notes to share **
![35K Successful entry : Interview with ant financial Java Back end experience !「 Including interview questions + answer 」](https://s2.51cto.com/images/20210808/1628416910569440.jpg)![](https://s2.51cto.com/images/20210808/1628416910678066.jpg)
  • 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.
版权声明
本文为[Flowers without hair loss]所创,转载请带上原文链接,感谢
https://qdmana.com/2021/08/20210808181229384n.html

  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