vue 2.0版本----》常用代码说明

时间:2022-12-24 09:09:03

------------------------------------------代码不显示--------------------------------------------

[v-cloak] {
  display: none;
}

<li v-for="(list, index) in info.Product_List.data" v-cloak>

-----------------------------------------vue2.0 $set变更--------------------------------------------

var list = new Vue({
  el:"#list2",
  data:{
    info:""
  },
  methods:{
  ajax_data:function(cache){
    var _self=this;
    ajax_ing =$.ajax({
      url:"url",
      type:"get",
      data:{},
      dataType:"json",
      success:function(data){

        Vue.set(list ,"info",data.info);
        list.$nextTick(function () {

        })
      }
    })
   }
  }
})

-----------------------------------------vue2.0 src or url渲染时加路径--------------------------------------------

v-bind:src="'../pc/images/'+list.gameImg"

-----------------------------------------vue2.0 获取该数据的dom--------------------------------------------

<span v-on:click="choose($event)"></span>

choose:function(event){
    var el = event.currentTarget;
    $(el).find("input").attr("checked","checked")
}