• 学习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>

  • 相关阅读:
    PTA乙级 (*1034 有理数四则运算 (20分)(string.append()))
    Nginx反向代理部署Node.js应用配置方法
    js处理字符串的用法小结
    从零开始基于webpack搭建react全家桶
    Linux常用指令
    matplotlib作图时中文字体乱码解决办法
    大话数据结构 串
    大话数据结构 队列
    大话数据结构 栈
    大话数据结构 线性表
  • 原文地址:https://www.cnblogs.com/kttbk/p/8031860.html
Copyright © 2020-2023  润新知