


How to componentize the common header of the page in Vue (detailed tutorial)
This article mainly introduces the method of vue componentizing the common header of the page. The editor thinks it is quite good. Now I will share it with you and give it as a reference. Let’s follow the editor and take a look.
This article introduces the method of vue componentizing the common header of the page and shares it with everyone. The details are as follows:
Uh... pick up the previous one again vue-cli quickly generates projects.
I previously made a multi-page transformation and introduced the UI component of vux. This time, based on this project, let’s talk about components in vue.
Don’t ask me why I always write blogs about vue, it’s all for livelihood (………………)
This is the official document address (https://cn. vuejs.org/v2/guide/components.html#What is a component?), I have written a lot about components, and you will know at a glance that this is very useful.
I won’t introduce the concepts of some components one by one. The official documents are very detailed.
Let’s get to the point and download the project directly
One takes out the previous project
2 Under this requirement, it is natural to use our components and add the following code to index.js.
Vue.component('header-item', { props: ['message', 'backUrl'], template: `<header class="evaluate-header"><router-link :to="backUrl"><span><i class="iconfont"></i></span></router-link> <p><span>{{message}}</span></p> </header>` }) // props用来传递数据 //template 一个html结构的模板
It should be noted that because vue routing was used in the previous project, the backUrl parameter is a configurable route and can be configured according to your own needs in the actual project.
三 Add code to the other two demo pages
Add the following code to demo1.vue
<header-item message="我是demo1头部" backUrl="/"></header-item>
Add the following code to demo2.vue
<header-item message="我是demo2头部" backUrl="/"></header-item>
Fourth, finally run and open the web page to see
Continue to dump the github address of the previous project https://github.com /qianyinghuanmie/vue-cli-
The above is what I compiled for everyone. I hope it will be helpful to everyone in the future.
Related articles:
How to enlarge the image in JavaScript
##How to implement the China map in vue vuex axios echarts
How to switch between styles in vue
Solve the problem of the input box being blocked by the input method
How to solve the problem of soft keyboard blocking the input box in js
How to implement component interaction in Angular2
The above is the detailed content of How to componentize the common header of the page in Vue (detailed tutorial). For more information, please follow other related articles on the PHP Chinese website!

JavaScript runs in browsers and Node.js environments and relies on the JavaScript engine to parse and execute code. 1) Generate abstract syntax tree (AST) in the parsing stage; 2) convert AST into bytecode or machine code in the compilation stage; 3) execute the compiled code in the execution stage.

The future trends of Python and JavaScript include: 1. Python will consolidate its position in the fields of scientific computing and AI, 2. JavaScript will promote the development of web technology, 3. Cross-platform development will become a hot topic, and 4. Performance optimization will be the focus. Both will continue to expand application scenarios in their respective fields and make more breakthroughs in performance.

Both Python and JavaScript's choices in development environments are important. 1) Python's development environment includes PyCharm, JupyterNotebook and Anaconda, which are suitable for data science and rapid prototyping. 2) The development environment of JavaScript includes Node.js, VSCode and Webpack, which are suitable for front-end and back-end development. Choosing the right tools according to project needs can improve development efficiency and project success rate.

Yes, the engine core of JavaScript is written in C. 1) The C language provides efficient performance and underlying control, which is suitable for the development of JavaScript engine. 2) Taking the V8 engine as an example, its core is written in C, combining the efficiency and object-oriented characteristics of C. 3) The working principle of the JavaScript engine includes parsing, compiling and execution, and the C language plays a key role in these processes.

JavaScript is at the heart of modern websites because it enhances the interactivity and dynamicity of web pages. 1) It allows to change content without refreshing the page, 2) manipulate web pages through DOMAPI, 3) support complex interactive effects such as animation and drag-and-drop, 4) optimize performance and best practices to improve user experience.

C and JavaScript achieve interoperability through WebAssembly. 1) C code is compiled into WebAssembly module and introduced into JavaScript environment to enhance computing power. 2) In game development, C handles physics engines and graphics rendering, and JavaScript is responsible for game logic and user interface.

JavaScript is widely used in websites, mobile applications, desktop applications and server-side programming. 1) In website development, JavaScript operates DOM together with HTML and CSS to achieve dynamic effects and supports frameworks such as jQuery and React. 2) Through ReactNative and Ionic, JavaScript is used to develop cross-platform mobile applications. 3) The Electron framework enables JavaScript to build desktop applications. 4) Node.js allows JavaScript to run on the server side and supports high concurrent requests.

Python is more suitable for data science and automation, while JavaScript is more suitable for front-end and full-stack development. 1. Python performs well in data science and machine learning, using libraries such as NumPy and Pandas for data processing and modeling. 2. Python is concise and efficient in automation and scripting. 3. JavaScript is indispensable in front-end development and is used to build dynamic web pages and single-page applications. 4. JavaScript plays a role in back-end development through Node.js and supports full-stack development.


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

Atom editor mac version download
The most popular open source editor

Notepad++7.3.1
Easy-to-use and free code editor
