Getting started with Vue.js
Introduction
vue.js is a client-side js library that can be used to develop single-page applications. In order to select a project, I looked at angular, react, and vuejs one after another. I admired the first two and loved the latter. Because it is simple and clean, and it also has advanced web components implementation. Even if there isn't much documentation, I'd choose it. Next, we first create a starting project and go over the concepts and components involved in the development process.
vue.js
The development process of decent vuejs is almost always combined with webpack and babel. For those who like to hack from scratch, let me tell you that the configuration is extremely cumbersome. Fortunately, vue.js provides a tool called vue-cli. Can be used to quickly build the starting code for a single-page application. It only takes a minute to launch commonly used development features:
Scaffolding code available.
Hot reload. Automatically reload after component code is updated
Static code inspection.
ES6 language features
Tool preparation
We need to use vue-cli to create a scaffolding project.
Install vue-cli
$ npm install -g vue-cli
Confirm the node version
My version is
$ node -v
v5.0.0
$ npm -v
3.10.6
Many problems may occur if they occur It depends on the version, the suggestion is the same as mine.
Create a new project
Execution:
$ vue init webpack my-project
The second parameter webpack specifies to create a vuejs project based on the "webpack" template. This template will create a webpack scaffolding code.
However, what is webpack? It itself is a packaging tool that can package js, css, and image into one or more js files, and can support various loaders as plug-ins to convert different types of files. In fact, webpack uses the plug-in vue-loader to perform format conversion when loading Vue type files, and translates Vue type files into js files that the browser can recognize.
Attention for Chinese users: The vue init command uses npm. The npm warehouse is often slow or blocked. You can use domestic mirrors. Just edit ~/.npmrc and add the following content:
registry = https://registry.npm.taobao.org
This method can be much faster.
The currently available templates are:
webpack - Through webpack and the vue-loader plug-in, you can call babel to compile the .vue file into a js file that the client can recognize. Hot loading, code inspection, and testing can also be provided by default.
webpack-simple - The simplest webpack and vue-loader plugin.
browserify - Through the combination of Browserify + vueify, babel can be called to compile the .vue file into a js file that can be recognized by the client. Hot loading, code inspection, and testing can also be provided by default.
browserify-simple - The simplest Browserify + vueify plugin.
Theoretically, webpack and browserify have similar functions, and both can be used as packaging tools. But webpack is that popular tool that has very little documentation, but everyone is vying to use it. So, let’s not worry about it and use webpack first.
Install dependencies, go to http://localhost:8080 to check the effect.
View vue files
vue files are a trinity. That is to say, css, html, and js are all in one file, and they are separated using tags. In order to better view the structure, it is recommended to first install the highlight plug-in corresponding to the editor.
Install syntax highlighting
The editor I am accustomed to using is sublime text. Installing the plug-in can identify all vuejs component codes with the extension .vue and give them highlights to facilitate code reading and writing. This plug-in is called vue-syntax-highlight and is officially provided by vuejs. It's located at github.com. Just clone it into your Sublime package directory. On my computer, the Sublime package directory is /Users/lcj/Library/Application Support/Sublime Text 3/Packages, so the installation process is
$ cd my-project $ npm install $ npm run dev
and then restart. After reading the code, all files with a .vue extension will have corresponding highlights.
View vue
There is a component code in the starting code, which is in src/hello.vue. View:
cd /Users/lcj/Library/Application\ Support/Sublime\ Text\ 3/Packages git clone https://github.com/vuejs/vue-syntax-highlight
The file is divided into three parts. The tag is surrounded by html code; the
AI-powered app for creating realistic nude photos Online AI tool for removing clothes from photos. Undress images for free AI clothes remover Swap faces in any video effortlessly with our completely free AI face swap tool! Easy-to-use and free code editor Chinese version, very easy to use Powerful PHP integrated development environment Visual web development tools God-level code editing software (SublimeText3)
Hot AI Tools
Undresser.AI Undress
AI Clothes Remover
Undress AI Tool
Clothoff.io
Video Face Swap
Hot Article
Hot Tools
Notepad++7.3.1
SublimeText3 Chinese version
Zend Studio 13.0.1
Dreamweaver CS6
SublimeText3 Mac version
Hot Topics
1387
52

When using the Vue framework to develop front-end projects, we will deploy multiple environments when deploying. Often the interface domain names called by development, testing and online environments are different. How can we make the distinction? That is using environment variables and patterns.

The difference between componentization and modularization: Modularization is divided from the perspective of code logic; it facilitates code layered development and ensures that the functions of each functional module are consistent. Componentization is planning from the perspective of UI interface; componentization of the front end facilitates the reuse of UI components.

Ace is an embeddable code editor written in JavaScript. It matches the functionality and performance of native editors like Sublime, Vim, and TextMate. It can be easily embedded into any web page and JavaScript application. Ace is maintained as the main editor for the Cloud9 IDE and is the successor to the Mozilla Skywriter (Bespin) project.

Foreword: In the development of vue3, reactive provides a method to implement responsive data. This is a frequently used API in daily development. In this article, the author will explore its internal operating mechanism.

Vue.js has become a very popular framework in front-end development today. As Vue.js continues to evolve, unit testing is becoming more and more important. Today we’ll explore how to write unit tests in Vue.js 3 and provide some best practices and common problems and solutions.

In Vue.js, developers can use two different syntaxes to create user interfaces: JSX syntax and template syntax. Both syntaxes have their own advantages and disadvantages. Let’s discuss their differences, advantages and disadvantages.

How to handle exceptions in Vue3 dynamic components? The following article will talk about Vue3 dynamic component exception handling methods. I hope it will be helpful to everyone!

In the actual development project process, sometimes it is necessary to upload relatively large files, and then the upload will be relatively slow, so the background may require the front-end to upload file slices. It is very simple. For example, 1 A gigabyte file stream is cut into several small file streams, and then the interface is requested to deliver the small file streams respectively.
