vue脚手架

vue-cli 基于webpack。帮助我们完成了对项目的基本架构,冗余代码比较多 ,资源的浪费

1.全局安装vue的脚手架
cnpm install @vue/cli -g
2.查看版本号
vue -v
3.创建项目
  1. vue create demo

    Vue CLI v4.2.2
    ? Please pick a preset: (Use arrow keys)
    default (babel, eslint) //第一项是默认
    > Manually select features //自定义
  2. 选择自定义

    Vue CLI v4.2.2
    ? Please pick a preset: Manually select features
    ? Check the features needed for your project: (Press <space> to select, <a> to toggle all, <i> to invert selection)
    >(*) Babel //es6转es5一些插件
    ( ) TypeScript
    ( ) Progressive Web App (PWA) Support
    (*) Router //路由
    (*) Vuex
    (*) CSS Pre-processors //预处理语言
    (*) Linter / Formatter //规范代码书写
    ( ) Unit Testing
    ( ) E2E Testing
  3. 是否设置历史模式的路由器

    ? Use history mode for router? (Requires proper server setup for index fallback in production) (Y/n)
    //使用历史模式的路由器?(需要为生产环境中的索引回退进行适当的服务器设置) Y
  4. 选择预处理语言

    ? Pick a CSS pre-processor (PostCSS, Autoprefixer and CSS Modules are supported by default): (Use arrow keys)
    > Sass/SCSS (with dart-sass)
    Sass/SCSS (with node-sass)
    Less
    Stylus
    //选择 Sass/SCSS (with dart-sass)
  5. 选择ESLint的规范

     Pick a linter / formatter config: (Use arrow keys)
    ESLint with error prevention only
    ESLint + Airbnb config
    > ESLint + Standard config // 选择标准规范
    ESLint + Prettier
  6. 在什么时候结构化代码

    ? Pick additional lint features: (Press <space> to select, <a> to toggle all, <i> to invert selection)
    >(*) Lint on save //保存时
    ( ) Lint and fix on commit //提交时
  7. 每个插件的配置项写在单独的文件夹还是package.json中

     Where do you prefer placing config for Babel, ESLint, etc.? (Use arrow keys)
    > In dedicated config files
    In package.json //选哪个都可以
  8. 配置完成,下载代码

4.进入项目
cd demo
4.运行项目
npm run server
5.编译打包
npm run build  //编译打包   线上环境

文件结构

node_modules :项目所依赖的安装包
public :项目当中的页面
<noscript>
<strong>We're sorry but one doesn't work properly without JavaScript enabled. Please enable it to continue.</strong>
</noscript>
//页面不支持js时 输出代码
src:开发环境
assets:存放静态资源。图片,公共样式
component:存放组件
router:路由的配置
views:项目当中的页面
store:vuex
main.js 项目的入口文件
APP.vue
dist:
编译打包后的文件目录
文件不能直接打开 引入资源用的是绝对路径 换成相对路径
xxx.map 可以删除进一步降低体积大小
main.js文件
import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store' Vue.config.productionTip = false new Vue({
router,
// store,
render: h => h(App)
}).$mount('#app')
render函数
  • render函数可以用js语言来构建DOM
 new Vue({
el :"#root",
render(createElement){
return createElement("h5","123")
}
})
$mount
  • $mount()为手动挂载,在项目中可用于延时挂载(例如在挂载之前要进行一些其他操作、判断等),之后要手动挂载上。

  • new Vue时,el和$mount并没有本质上的不同。

最新文章

  1. ArcGIS Engine 刷新问题
  2. 多次快速点击相同button导致重复响应的问题
  3. IOS 自定义按钮(代码实现)+九宫格
  4. 通过Profiles查看create语句的执行时间消耗 (转)
  5. 黑马程序员——Java高级应用(一)
  6. C 语言中实现数据与方法的封装
  7. Codeforces 484E Sign on Fence(是持久的段树+二分法)
  8. [google面试CTCI] 2-1.移除链表中重复元素
  9. 用Perl做个简单”下载者病毒”
  10. 大数据阶乘(The factorial of large data)
  11. Swashbuckle Swagger组件扩展
  12. Visual Studio进行Web性能测试- Part I
  13. canvas画多边形
  14. solr中的一些常见错误
  15. java 设计模式参考资料
  16. ALGO-149_蓝桥杯_算法训练_5-2求指数
  17. Linux-mkdosfs格式化磁盘命令(15)
  18. C# 地磅串口编程
  19. Error 之 只能在执行Render() 的过程中调用 RegisterForEventValidation;
  20. BUCTOJ1073

热门文章

  1. MQ使用:apollo和rabbitmq
  2. Mysql中使用mysqldump进行导入导出sql文件
  3. 使用ajax向后台发送请求跳转页面无效的原因
  4. Excel查找匹配函数的16种方法
  5. 7.JavaSE之类型转换
  6. Java入门 - 面向对象 - 06.接口
  7. (数据科学学习手札73)盘点pandas 1.0.0中的新特性
  8. [组合数学][多项式][拉格朗日插值]count
  9. ElEmentUI选择器弹出框定位错乱问题解决(弹出框出现在左上角)
  10. 玩转Django2.0---Django笔记建站基础十三(第三方功能应用)