H5 vue 初识

H5 vue 初识


1 . 开始构建一个项目

使用vue init webpack test(项目文件夹名)命令初始化一个vue项目

vue init webpack test(项目文件夹名)
  1. 开始构建环境
npm run start
或
npm run dev

3.vue模板

<template>
  <div class="list">list</div>
</template>

<script >
import HomeHeader from './components/Header'
import axios from 'axios'

export default {
  name: 'List',
  // 局部组件
  components: {
    HomeHeader
  },
  props: {
    list: Array
  },
  data () {
    return {
      iconList: [{
        id: '0001',
        imgUrl: 'http://img1.qunarzz.com/piao/fusion/1803/95/f3dd6c383aeb3b02.png',
        desc: '景点门票景点门票景点门票'
      }]
    }
  },
  methods: {
    getHomeInfo () {
      axios.get('/api/index.json')
        .then(this.getHomeInfoSucc)
    },
    getHomeInfoSucc (res) {
      console.log(res)
      res = res.data
      if (res.ret && res.data) {
        const data = res.data
        this.city = data.city
        this.list = data.swiperList
      }
    }
  },
  mounted () {
    this.getHomeInfo()
  }
}
</script>

<style lang="stylus" scoped>
@import '~styles/mixins.styl'
.list
    color: red

</style>

  1. div 居中 --- 绝对定位和0
.homeNav-img-div {
        position: absolute;
        width: 1.4rem;
        height: .5rem;
        line-height: .25rem;
        text-align: center;
        margin: auto; 
        top: 0; left: 0; bottom: 0; right: 0;
    }
  1. div 宽高比 显示
    html
<div class="homeIcon">
        <div class="iconContent">
            
        </div>
    </div>

css

.homeIcon
    position relative
    width: 100%
    height 0
    padding-bottom 31%
    background-color yellow
    .iconContent
        position:absolute;
        top: 0;
        left: 0;
        width: 100%
        height: 100%
        background-color: blue
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • 概要 64学时 3.5学分 章节安排 电子商务网站概况 HTML5+CSS3 JavaScript Node 电子...
    阿啊阿吖丁阅读 9,308评论 0 3
  • 解读报告的念头是从双证班结束前的分享开始的,我看着桌子上来自各地的纯净水/矿泉水/苏打水说“DISC是纯净的水,加...
    念即起行阅读 231评论 0 0
  • 七羽夕安是谁? 是我。 那天注册简书发布信息急于取名,我无意看到了一张漂亮的图片 一片羽毛在夕阳下金光闪闪,有点像...
    七羽夕安阅读 509评论 0 1
  • 我曾经不怎么爱说话,不愿意和别人有很多的交谈,比较喜欢待在自己的世界里,因为自己的世界里没有比较,我就是我。喜欢沉...
    葛小婷阅读 1,206评论 0 5
  • 有一些“短、平、快”的项目,经费本来就少,用户对质量要求也马马虎虎。为了能多挣一点钱,开发方不得不采用“偷工减料”...
    给你一颗小瓜子阅读 419评论 0 1