Communication between non-parent and child components

1. Provide/Inject.

  • There is a provide option in the parent component to provide data;
  • The p child component has an Inject option to start using this data;

2. Code implemented in the parent component

<template> <div> <home></home> <button @click="addName">+name</button> </div> </template> <script> import Home from "./Home.vue"; Import {computed} from 'vue' export default {components: {Home}, // provide: {// name1: "Why ", // age: 18, //} // provide() {return {name1: "why", age: 18, // Computed here can make this responsive, assign length, computed returns value length: computed(()=>this.names.length),//ref object}; }, data() { return{ names:['abc','asv','als'] } }, methods: { addName(){ this.names.push("why") console.log(this.names) } } }; </script> <style scoped> </style>Copy the code

3. Code implemented in HomeContent component

<template> <div> HomeContent:{{name1}}--{{age}}--{{length}} </div> </template> <script> export default {// Accept parameter inject: ["name1","age","length"] } </script> <style scoped> </style>Copy the code

Second, linear algebra learning

1. Elementary transformation

  • Elementary matrix: A matrix obtained by a transformation of the identity matrix.
  • Elementary matrix —-> invertible matrix

2. Left row and right column

  • Perform an elementary row operation on A <==> left-multiply the m-order elementary matrix
  • Perform an elementary column transformation on A <==> multiply right by the NTH order elementary matrix
  • Details see line generation notes, mainly here is not easy to write. Matrices, subscripts, that’s not easy to express.

3. Python crawler learning

1. Here is no more to say, directly on the code

import os import requests from bs4 import BeautifulSoup # 1. Take data url = "https://movie.douban.com/top250" # purpose, disguised as a browser header = {the user-agent: "Mozilla / 5.0 (iPhone; CPU iPhone OS 13_2_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, } resp =requests. Get (URL,headers = header) # print(resp) # 2 HTML = resp.text # print(HTML) # print(type(soup)) #3 Find_all (class_=" PIC ") print(content_all) os.mkdir("images") Os. chdir("images") # loop through each item in content_all: ImgContent = item.find(name = "img") # print(imgContent) # attrs imgContent.attrs["alt"] imgUrl = imgContent.attrs['src'] # print(imgUrl) # imgUrlHd = imgUrl.replace("s_ratio_poster", "m") # print(imgUrlHd) # imgResponse = requests.get(imgUrlHd) # img = requests.get(imgResponse) resp = requests.get(imgUrl) img = resp.content with open(f"{imgName}.jpg", "wb") as f: # use write() to write the image to f.write(img) resp.close()Copy the code

Remarks: Personal study notes, record their own learning experience.