zoukankan      html  css  js  c++  java
  • 学习vue第一篇记录

    首先,下载vue.js引入包里。

    用到的文件可以从该网址引入:http://www.bootcdn.cn/vue/

    1.赋值

    html:

    <div id="app" title="试用title属性">
    {{ message }}
    </div>

    js:

    <script>

    var app = new Vue({
    el: '#app',
    data: {
    message: 'Hello Vue!'
    }
    })

    </script>

    2.循环列表:

    html:

    <div id="designer" style="height:100%;">
      <div class="every_designer_div" v-for ="item in lists" >
        <div class="img_left_div"><img v-bind:src="item.designer_list_img" class="designerPhoto" ></div>
        <div class="font_container_right_div">
          <div class="firstLine" style="font-size: 14px;"><label class="designerName">{{item.designer_name}}</label>{{item.designer_title}}</div>
          <div>从业年限:{{item.career_age}}年</div>
          <div class="overflow_ellipsis">设计理念:{{item.designer_theory}}</div>
          <div class="overflow_ellipsis">代表作品:{{item.designer_name}}</div>
        </div>
      </div>
    </div>

    js:

    <script>

    var demo=new Vue({

      el:'#designer',

      data: {

        lists:[],

        getImgUrl: 'http://xxxxxxxxxxxx' //待调用的接口地址        

      },

      created: function(){

        this.getImg() //定义方法

      },

      methods: {

      getImg: function(){

        var that = this;

        that.$http({ //调用接口

        method:'GET',

        url:this.getImgUrl, //this指data

        params: {
          start:'1',//请求的参数
          limit:'20'
        },


      }).then(function(response){ //接口返回数据
          console.log(response.data.data)
          this.lists=response.data.data;

        },function(error){

         })

        }

      }

    })
    </script>

  • 相关阅读:
    zip加密-字符串加密成字符串
    语言学习第一天
    localStorage和sessionStorage数据存储
    ValueOf()和toString()
    call()与apply()区别typeof和instanceof的区别
    javaScript判断手机型号
    HTML&CSS
    Doctype 严格模式与混杂模式-如何触发这两种模式,区分它们有何意义?
    获得地址栏内的参数
    私有变量
  • 原文地址:https://www.cnblogs.com/kttbk/p/8031860.html
Copyright © 2011-2022 走看看