Detailed explanation for novices learning Vue
This time I will bring you a detailed explanation for novices learning vue. What are the precautions for novices learning vue. The following is a practical case, let’s take a look.
One of the best frameworks for vue currentlyFirst of all, we follow the official website’s documentation#Special attentionVue.js does not support IE8 and its The following version, because Vue.js uses ECMAScript 5 features that IE8 cannot emulate. Vue.js supports all ECMAScript 5-compatible browsers.Change logThe change log of each version can be found on GitHub.
$ npm install vue
# 全局安装 vue-cli$ npm install --global vue-cli# 创建一个基于 webpack 模板的新项目$ vue init webpack my-project# 安装依赖,走你$ cd my-project $ npm install $ npm run dev
## The #CLI tool assumes a certain level of familiarity with
Node.jsand related build tools. If you're new to Vue, we highly recommend reading through the guide without a build tool and getting familiar with Vue itself before delving into the CLI. After following the process
will appear.babelrc
presets are presets
Introduction to project files
node_modules are installed by us through npm The dependent code library
src directory is where we store the source code of the project. All the code we develop will be placed in the src directory
The static folder is where third-party file resources are stored
//.editorconfig 编辑器的配置charset = utf-8 //编码indent_style = space //缩进的风格indent_size = 2 //缩进的大小是两个end_of_line = lf //换行符的风格insert_final_newline = true //创建一个文件,会自动插入新行trim_trailing_whitespace = true //会自动移除行尾的多余空格
. eslintignore: Ignore the syntax check
After understanding the project file, let’s understand how the current code runs
index.html is theentry file
index We know that his js and css will be dynamically inserted into this page
Also look at the dom structure,
He actually It is a vue component
The entrance JS of our page is actually this main.js
There is a red line marked here. It is a compiler problem. It can be recognized by adjusting it to es6 syntax
import Vue from 'vue'import Vue from './App'new vue ({ el: 'body'
components:{App}
})
We can see that this entry file relies on two
and one is App.vue. It can be simply written directly as App
and then pass new Vue Instantiate a vue
components:{App}Registers a current App plug-in. This syntax is an abbreviation of es6, corresponding to With es5 App:App can simplify our writing through the writing method of es6. We know that this app corresponds to this app.vue
. Then let’s take a look at app.vue
which is divided into < ;srcipt>
template is a templatesrcipt is a JS
style is a css style
The page structure is combined with the page to correspond and look at the page structure
This hello is a vue The component corresponds to hello.vue
in components. In App.vue, a sub-component hello is registered through components. It must be noted that we can only use the hello tag by registering it through components
property
, otherwise That's not possible. You can try the hello comment in componentsAuto-formatting shortcut key ctrl+alt+L
Now let’s take a look at hello.vue
The code structure msg corresponds to this data msgWe define a data fun
in the definition of vue. It can return an obj. All the values in this obj will be added to its dependencies, and then the msg is accessed in the template. You can access the msg in this data through the msg in the template
export default This is the syntax sugar provided by vue. You can define a component through obj
will be in the import of App.vue Hello from'./components/hello'
That is to say, the object in the data in hello.vue will be assigned to this hello
而在components{ Hello相当于Hello:Hello }
That is to say, the key of components is hello Its value is the value of export default
I believe you have mastered the method after reading the case in this article. For more exciting information, please pay attention to other related articles on the PHP Chinese website!
Related reading:
Front-end entry to css3How to solve the css Hack of IE11How axios makes HTTP request client based on Promise
The above is the detailed content of Detailed explanation for novices learning Vue. For more information, please follow other related articles on the PHP Chinese website!

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

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

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

Windows operating system is one of the most popular operating systems in the world, and its new version Win11 has attracted much attention. In the Win11 system, obtaining administrator rights is an important operation. Administrator rights allow users to perform more operations and settings on the system. This article will introduce in detail how to obtain administrator permissions in Win11 system and how to effectively manage permissions. In the Win11 system, administrator rights are divided into two types: local administrator and domain administrator. A local administrator has full administrative rights to the local computer

Detailed explanation of division operation in OracleSQL In OracleSQL, division operation is a common and important mathematical operation, used to calculate the result of dividing two numbers. Division is often used in database queries, so understanding the division operation and its usage in OracleSQL is one of the essential skills for database developers. This article will discuss the relevant knowledge of division operations in OracleSQL in detail and provide specific code examples for readers' reference. 1. Division operation in OracleSQL

When editing text content in Word, you sometimes need to enter formula symbols. Some guys don’t know how to input the root number in Word, so Xiaomian asked me to share with my friends a tutorial on how to input the root number in Word. Hope it helps my friends. First, open the Word software on your computer, then open the file you want to edit, and move the cursor to the location where you need to insert the root sign, refer to the picture example below. 2. Select [Insert], and then select [Formula] in the symbol. As shown in the red circle in the picture below: 3. Then select [Insert New Formula] below. As shown in the red circle in the picture below: 4. Select [Radical Formula], and then select the appropriate root sign. As shown in the red circle in the picture below:

The modulo operator (%) in PHP is used to obtain the remainder of the division of two numbers. In this article, we will discuss the role and usage of the modulo operator in detail, and provide specific code examples to help readers better understand. 1. The role of the modulo operator In mathematics, when we divide an integer by another integer, we get a quotient and a remainder. For example, when we divide 10 by 3, the quotient is 3 and the remainder is 1. The modulo operator is used to obtain this remainder. 2. Usage of the modulo operator In PHP, use the % symbol to represent the modulus

Title: Learn the main function in Go language from scratch. As a simple and efficient programming language, Go language is favored by developers. In the Go language, the main function is an entry function, and every Go program must contain the main function as the entry point of the program. This article will introduce how to learn the main function in Go language from scratch and provide specific code examples. 1. First, we need to install the Go language development environment. You can go to the official website (https://golang.org

C Language or C: Which Is More Suitable for New Programmers In the era of rapid development of modern technology, learning programming has become an increasingly popular choice, whether as part of career development or as a way to improve logical thinking skills. Among many programming languages, C language and C are both very classic and representative languages. Many people are confused about how to choose C language or C as an entry-level programming language. So, is C language more suitable for programming novices, or is C more suitable? Need specific code examples to

Original author: Minty, encryption KOL Original compilation: Shenchao TechFlow If you know how to use it, Dune is an all-in-one alpha tool. Take your research to the next level with these 20 Dune dashboards. 1. TopHolder Analysis This simple tool developed by @dcfpascal can analyze tokens based on indicators such as holders’ monthly activity, number of unique holders, and wallet profit and loss ratio. Visit link: https://dune.com/dcfpascal/token-holders2. Token Overview Metrics @andrewhong5297 created this dashboard which provides a way to evaluate tokens by analyzing user actions

Detailed explanation of how to operate hidden applications on Black Shark mobile phones As mobile phone functions continue to improve, modern people’s needs for mobile phones are becoming more and more diverse. Some people may save some private information or personal photos on their mobile phones. In order to protect privacy and security, many mobile phones provide the function of hiding applications. As a mobile phone specially designed for gamers, Black Shark also provides users with the function of hiding applications. Let’s introduce in detail the operation method of hidden applications on Black Shark mobile phone. Step 1: Open the “Settings” interface. First, the user needs to open the Black Shark mobile phone.
