Vue组件:网格系统,row & col

    <g-row class="demoRow" align="center" gutter="20">
        <g-col span="8"><div class="demoCol">hi</div></g-col>
        <g-col span="8"><div class="demoCol">hi</div></g-col>
    </g-row>
    <g-row class="demoRow" align="left" gutter="20">
        <g-col span="6"><div class="demoCol">hi</div></g-col>
        <g-col span="6"><div class="demoCol">hi</div></g-col>
    </g-row>
    <g-row class="demoRow" align="right" gutter="20">
        <g-col span="4"><div class="demoCol">hi</div></g-col>
        <g-col span="4"><div class="demoCol">hi</div></g-col>
        <g-col span="4"><div class="demoCol">hi</div></g-col>
        <g-col span="4"><div class="demoCol">hi</div></g-col>
    </g-row>
    <g-row class="demoRow" gutter="20">
        <g-col span="4"><div class="demoCol">hi</div></g-col>
        <g-col span="4"><div class="demoCol">hi</div></g-col>
        <g-col span="4"><div class="demoCol">hi</div></g-col>
        <g-col span="4"><div class="demoCol">hi</div></g-col>
        <g-col span="4"><div class="demoCol">hi</div></g-col>
        <g-col span="4"><div class="demoCol">hi</div></g-col>
    </g-row>

需求

1.实现 div 分成各等分(默认最多24分)
2.gutter 缝隙
3.响应各媒体分辨率


知识点

  • vue组件三板斧:<template> <script> <style>
  • props
  • v-bind,缩写为 :
  • props中的类型检测器,validator()
  • ES6 ,模板字符串插入表达式,:class="{[`icon-${iconPosition}`]:true}"

  • computed
  • mounted
  • ES,array.push
  • ES6 ,扩展运算符
  • ES6 ,解构赋值
  • css,媒体响应,@media
  • css(display: flex;) (flex-wrap: wrap;) (justify-content: flex-start/center/flex-end)
  • scss,for语法,@for $n from 1 through 24 {}
  • scss,插值语法,&.#{$class-prefix}#{$n} {}

关键点

  • 使用 v-bindcomputed 动态绑定 prop
  • 了解生命周期
  • created 是生成一个不加载页面中的对象,mounted 是将对象挂到页面中
  • 使用 mountedthisprops 数据传递给子组件
  • 使用 scss 插值语法将各 class 对应各自媒体响应的样式

代码

row.vue
col.vue

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • # 传智播客vue 学习## 1. 什么是 Vue.js* Vue 开发手机 APP 需要借助于 Weex* Vu...
    再见天才阅读 3,629评论 0 6
  • 这篇笔记主要包含 Vue 2 不同于 Vue 1 或者特有的内容,还有我对于 Vue 1.0 印象不深的内容。关于...
    云之外阅读 5,082评论 0 29
  • vue.js是什么 是一套构建用户界面的渐进式框架 vue应用组成 一个 Vue 应用由一个通过new Vue创建...
    多多酱_DuoDuo_阅读 1,045评论 0 2
  • 时空割断了凝望......... ­ 我站在窗前,望着窗外天霖潺潺,任雾水模糊了明睛 ­ 生命允许承载的感动,或许...
    笑揖轻风阅读 402评论 3 2
  • 我们是他人生命里的旅行者, 为了寻找生命中的Soul mate, 终其一生,行走在漫长的旅途上。 年轻时,总执着于...
    苏翰墨阅读 577评论 0 0