In early full-stack development, communication overhead was high, roles were fuzzy, and it was tough to manage or extend projects.
Today’s standard is frontend-backend separation, driven by API documentation.
Frontend-Backend Separation
Frontend sends parameters and parses response data based on API docs. Backend receives parameters and responds as per API docs.
Dev Workflow: Requirements Analysis -> API Definition (API Docs) -> Parallel Frontend/Backend Dev (following specs) -> Testing -> Frontend/Backend Integration Testing.
You can use YApi for testing before API development is complete.
Frontend Engineering
It’s about standardizing frontend dev tools, tech, processes, and experience for enterprise-level projects.
- Modularity: JS, CSS
- Componentization: UI structure, styles, behavior
- Standardization: Directory structure, coding, APIs
- Automation: Build, deploy, test
Vue CLI
Vue-cli is the official scaffold provided by Vue, used to quickly generate a Vue project template. It requires NodeJS.
Vue-cli offers the following features:
- Unified directory structure
- Local debugging
- Hot Reloading: No need to restart the app after code changes; the latest program loads automatically.
- Unit testing
- Integrated build and deployment
NodeJS
Install from the official website, then configure npm package location.
| |
Switch npm to the Taobao mirror.
| |
Install Vue-cli
| |
Verify successful installation
| |
Vue Project
You can create projects via CLI or a graphical interface.
| |
Directory Structure
Root directory:
node_modules: Contains all project dependencies.public: Static project files.src: Project source code.package.json: Basic module info, required dev modules, and version details.vue.config.js: Stores Vue configurations, such as proxy and port settings.
Inside the src folder:
assets: Static resources.components: Reusable components.router: Routing configuration.views: View components (pages).App.vue: The entry page (root component).main.js: The entry JavaScript file.
Running the Project
In VS Code, you can run it directly from the terminal panel.
From the command line:
| |
Changing the Port
In the vue.config.js file:
| |
Development Workflow
The entry file is src/main.js. Here’s the default content:
| |
The import keyword above means importing components; conversely, export means exporting them.
The Vue object code above is similar to:
| |
Vue component files end with .vue. Each component consists of three parts: <template>, <script>, and <style>.
| |