Table of Contents
Preface
Project directory structure
Home Backend Development PHP Tutorial Develop backend system based on vue modularization - build project

Develop backend system based on vue modularization - build project

Mar 30, 2018 pm 01:56 PM
Backstage Modular system

This article shares with you the modular development backend system based on vue. Interested friends can take a look at this article.

The article directory is as follows:
Based on vue modular development backend System - preparation work
Based on vue modular development backend system-building project

Preface

After getting familiar with the preparation tools mentioned in the previous article, now Start building your own project. This is a VUE project. Then use vue-cli to build it. Enter the following command

vue init webpack xxxx
Copy after login

During the building process, because of the need to standardize the code as mentioned before, I asked this question in eslint , please reply Y. After everything is over, let's take a look at the directory structure

Project directory structure

Of course, some additions have been made to this directory, and remarks have been made (added) , the ones without remarks are the same

├── build                      // 构建相关  
├── config                     // 配置相关
├── dist                       // 打包之后相关
├── node_modules               // npm相关包
├── src                        // 代码
│   ├── api                    // 请求接口文件(加)
│   ├── assets                 // 静态资源(图片,样式等)
│   ├── components             // 全局公用组件
│   ├── directives             // 全局指令(加)
│   ├── mock                   // 项目mock 模拟数据(加)
│   ├── pages                  // 相关页面(加)
│   ├── router                 // 路由
│   ├── store                  // store管理(加)
│   ├── App.vue                // 入口页面
│   └── main.js                // 入口 加载组件 初始化等
├── static                     // 第三方不打包资源
├── .babelrc                   // babel-loader 配置
├── .eslintignore              // eslint 忽略项
├── .eslintrc.js               // eslint 配置项
├── .postcssrc.js              // postcss 配置项
├── .gitignore                 // git 忽略项
├── index.html                 // html模板
└── package.json               // package.json
Copy after login

Analyze these first, if you don’t see the node_modules folder, don’t worry about it for now, then look down and add api,directives,mock,pages,storeThese folders have their respective functions

  1. api:Interface for storing project simulation

  2. directives: Storage global directives of the project

  3. ##mock:Storage usagemock.jsSimulated data

  4. pages:Storage project-related pages

  5. store: Storage state management

After reading these, there is actually nothing interesting to see. These can be named whatever you like. Next, let’s talk about package.json

package.json

This is the file used by NPM to manage project packages.

Open this file and find the
devDependencies attribute, where we add the packages required by the project, for example:

  1. "axios": "^0.17. 0",//Request tool

  2. "js-cookie": "^2.2.0",//Cookie

  3. "lodash" : "^4.17.4",//Function library

  4. "mockjs": "^1.0.0",//Simulation data tool

  5. "vuex": "^3.0.1",//State management tool

  6. "vee-validate": "^2.0.0"//Form validation tool

If your file has been configured, then directly enter the following command

npm install --save-dev
Copy after login
When you enter like this, you will find that the download is very, very slow. Why? Because the package you downloaded may be from abroad, so~~We add

Taobao Mirror, as follows

npm install --save-dev --registry=http://registry.npm.taobao.org
Copy after login
Of course, if you add it one by one, I usually check the package first version, because sometimes some packages are beta versions, the command is as follows:

npm show 包名或者插件名称 versions --json
Copy after login
Then enter the following command:

npm install 包名或者插件名称@版本 --save-dev --registry=http://registry.npm.taobao.org
Copy after login
At this time we only need to drink a cup of tea and be quiet A handsome man or a beautiful girl is enough~~After the download is completed, you can see the

node_modules folder

Personal modification, for reference only

After completing the above steps, you still need to modify the configuration.

Modify port

First find the directory

config, then find the file index.js, open it and find ## For the configuration item of #dev, since the default port is 8080, in order to prevent port conflicts with other projects, find the port option and change it to your favorite port

The browser automatically opens the project after running

Find the

dev

configuration item as above, and then find autoOpenBrowser, the default isfalse, now changed to true.

Problems with loading resources after packaging

Due to the problem that pictures and styles do not appear after packaging, I don’t know if you have the same problem, so I have made the following modifications:

config

Find the file index.js in this directory, open the configuration item found in build, and add assetsPublicPath: './ 'Then find the file

utils.js

in the build directory, and then find the following code: <div class="code" style="position:relative; padding:0px; margin:0px;"><pre class="brush:php;toolbar:false">return ExtractTextPlugin.extract({     use: loaders,     fallback: 'vue-style-loader',   })</pre><div class="contentsignin">Copy after login</div></div> in the configuration item Add

publicPath: '../../'

Summary

This part is for reference only, if you can ignore it for now, it appears It is possible to look back at the same problem again and it will not hinder the construction of the project. Once the build is complete, let’s start coding!

Article

Developing a backend system based on vue modularization - preparation workDeveloping a backend system based on vue modularization-building a project

Related recommendations:

vue2.0 What should we pay attention to in axios cross-domain and rendering

How to implement inertial sliding & rebound Vue navigation bar on the mobile side

How to deal with refresh 404 after vue project is packaged

The above is the detailed content of Develop backend system based on vue modularization - build project. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

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

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Discuz background login problem solution revealed Discuz background login problem solution revealed Mar 03, 2024 am 08:57 AM

The solution to the Discuz background login problem is revealed. Specific code examples are needed. With the rapid development of the Internet, website construction has become more and more common, and Discuz, as a commonly used forum website building system, has been favored by many webmasters. However, precisely because of its powerful functions, sometimes we encounter some problems when using Discuz, such as background login problems. Today, we will reveal the solution to the Discuz background login problem and provide specific code examples. We hope to help those in need.

CUDA's universal matrix multiplication: from entry to proficiency! CUDA's universal matrix multiplication: from entry to proficiency! Mar 25, 2024 pm 12:30 PM

General Matrix Multiplication (GEMM) is a vital part of many applications and algorithms, and is also one of the important indicators for evaluating computer hardware performance. In-depth research and optimization of the implementation of GEMM can help us better understand high-performance computing and the relationship between software and hardware systems. In computer science, effective optimization of GEMM can increase computing speed and save resources, which is crucial to improving the overall performance of a computer system. An in-depth understanding of the working principle and optimization method of GEMM will help us better utilize the potential of modern computing hardware and provide more efficient solutions for various complex computing tasks. By optimizing the performance of GEMM

Huawei's Qiankun ADS3.0 intelligent driving system will be launched in August and will be launched on Xiangjie S9 for the first time Huawei's Qiankun ADS3.0 intelligent driving system will be launched in August and will be launched on Xiangjie S9 for the first time Jul 30, 2024 pm 02:17 PM

On July 29, at the roll-off ceremony of AITO Wenjie's 400,000th new car, Yu Chengdong, Huawei's Managing Director, Chairman of Terminal BG, and Chairman of Smart Car Solutions BU, attended and delivered a speech and announced that Wenjie series models will be launched this year In August, Huawei Qiankun ADS 3.0 version was launched, and it is planned to successively push upgrades from August to September. The Xiangjie S9, which will be released on August 6, will debut Huawei’s ADS3.0 intelligent driving system. With the assistance of lidar, Huawei Qiankun ADS3.0 version will greatly improve its intelligent driving capabilities, have end-to-end integrated capabilities, and adopt a new end-to-end architecture of GOD (general obstacle identification)/PDP (predictive decision-making and control) , providing the NCA function of smart driving from parking space to parking space, and upgrading CAS3.0

Always new! Huawei Mate60 series upgrades to HarmonyOS 4.2: AI cloud enhancement, Xiaoyi Dialect is so easy to use Always new! Huawei Mate60 series upgrades to HarmonyOS 4.2: AI cloud enhancement, Xiaoyi Dialect is so easy to use Jun 02, 2024 pm 02:58 PM

On April 11, Huawei officially announced the HarmonyOS 4.2 100-machine upgrade plan for the first time. This time, more than 180 devices will participate in the upgrade, covering mobile phones, tablets, watches, headphones, smart screens and other devices. In the past month, with the steady progress of the HarmonyOS4.2 100-machine upgrade plan, many popular models including Huawei Pocket2, Huawei MateX5 series, nova12 series, Huawei Pura series, etc. have also started to upgrade and adapt, which means that there will be More Huawei model users can enjoy the common and often new experience brought by HarmonyOS. Judging from user feedback, the experience of Huawei Mate60 series models has improved in all aspects after upgrading HarmonyOS4.2. Especially Huawei M

Which version of Apple 16 system is the best? Which version of Apple 16 system is the best? Mar 08, 2024 pm 05:16 PM

The best version of the Apple 16 system is iOS16.1.4. The best version of the iOS16 system may vary from person to person. The additions and improvements in daily use experience have also been praised by many users. Which version of the Apple 16 system is the best? Answer: iOS16.1.4 The best version of the iOS 16 system may vary from person to person. According to public information, iOS16, launched in 2022, is considered a very stable and performant version, and users are quite satisfied with its overall experience. In addition, the addition of new features and improvements in daily use experience in iOS16 have also been well received by many users. Especially in terms of updated battery life, signal performance and heating control, user feedback has been relatively positive. However, considering iPhone14

Are you worried about WordPress backend garbled code? Try these solutions Are you worried about WordPress backend garbled code? Try these solutions Mar 05, 2024 pm 09:27 PM

Are you worried about WordPress backend garbled code? Try these solutions, specific code examples are required. With the widespread application of WordPress in website construction, many users may encounter the problem of garbled code in the WordPress backend. This kind of problem will cause the background management interface to display garbled characters, causing great trouble to users. This article will introduce some common solutions to help users solve the trouble of garbled characters in the WordPress backend. Modify the wp-config.php file and open wp-config.

What are the computer operating systems? What are the computer operating systems? Jan 12, 2024 pm 03:12 PM

A computer operating system is a system used to manage computer hardware and software programs. It is also an operating system program developed based on all software systems. Different operating systems have different users. So what are the computer systems? Below, the editor will share with you what computer operating systems are. The so-called operating system is to manage computer hardware and software programs. All software is developed based on operating system programs. In fact, there are many types of operating systems, including those for industrial use, commercial use, and personal use, covering a wide range of applications. Below, the editor will explain to you what computer operating systems are. What computer operating systems are Windows systems? The Windows system is an operating system developed by Microsoft Corporation of the United States. than the most

Detailed explanation of how to modify system date in Oracle database Detailed explanation of how to modify system date in Oracle database Mar 09, 2024 am 10:21 AM

Detailed explanation of the method of modifying the system date in the Oracle database. In the Oracle database, the method of modifying the system date mainly involves modifying the NLS_DATE_FORMAT parameter and using the SYSDATE function. This article will introduce these two methods and their specific code examples in detail to help readers better understand and master the operation of modifying the system date in the Oracle database. 1. Modify NLS_DATE_FORMAT parameter method NLS_DATE_FORMAT is Oracle data

See all articles