前言
到今天为止,满打满算也搞了快三年的前端,jq框架、vue框架也搭过一些,但都是用一些半搭好的框架进行修改。今天准备重头开始搭建,看看途中会遇到些什么问题,也做一个记录。
一、搭建前的准备
无非是安装npm、node等等,网上的教程有很多,就不多说了直接跳入搭建。
二、搭建步骤
1.安装脚手架
npm install --global vue-cli
2.创建新项目
vue init webpack vue-iframe
Project name (vue-iframe) ; 设置你的项目名字;
Project description(A Vue.js project); 项目的描述;
Author ; 创建者;
Vue build (Use arrow keys); 这里使用Runtime-only模式,关于这两个模式的区别,有很多文章描述,但描述的都是八股文,有知道的大神可以分享分享;
Runtime + Compiler: recommended for most users
运行时+编译器:建议大多数用户使用
Runtime-only: about 6KB lighter min+gzip, but templates (or any Vue-specific HTML) are ONLY allowed in .vue files - render functions are required elsewhere
仅限运行时:大约6KB的轻量级min+gzip,但是模板(或任何特定于vue的html)只允许在.vue文件中使用——其他地方需要呈现函数
Install vue-router; 安装 vue-router,不多说,安装;
Use ESLint to lint your code;是否需要 js 语法检测,如果是多人维护或者有实习生,这个还是很有必要的,我选择Y;
检测的标准,选择宽松一点的standard
Standard (https://github.com/standard/standard)
Airbnb (https://github.com/airbnb/javascript)
none (configure it yourself)
Set up unit tests ; 是否安装 单元测试工具,不会用,埋坑待补充,选n;
Setup e2e tests with Nightwatch; 是否需要 端到端测试工具,同上,选n;
Should we run `npm install` for you after the project has been created? (recommended) (Use arrow keys);要不要创建好后安装。都行,我直接用yarn装了
Yes, use NPM
Yes, use Yarn
No, I will handle that myself
现在你就拥有一个最基本的框架了,我们跑一下yarn run dev。
总结
最基本的已经做好了,但我们距离真正的拿来开发使用,还是有所差距的。我会慢慢往后补充,文章中可能会有描述不好的,描述错误的,希望大家多多指教,有更好的想法可以提出来一起讨论。