亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

vuejs實(shí)現(xiàn)ready函數(shù)加載完之后執(zhí)行某個(gè)函數(shù)的方法

 更新時(shí)間:2018年08月31日 10:59:07   作者:huanghanqian  
這篇文章主要介紹了vuejs實(shí)現(xiàn)ready函數(shù)加載完之后執(zhí)行某個(gè)函數(shù)的方法,需要的朋友可以參考下

vue.js 教程

Vue.js(讀音 /vjuː/, 類(lèi)似于 view) 是一套構(gòu)建用戶(hù)界面的漸進(jìn)式框架。
Vue 只關(guān)注視圖層, 采用自底向上增量開(kāi)發(fā)的設(shè)計(jì)。
Vue 的目標(biāo)是通過(guò)盡可能簡(jiǎn)單的 API 實(shí)現(xiàn)響應(yīng)的數(shù)據(jù)綁定和組合的視圖組件。

我期望vue中tds全都渲染在界面上之后,再調(diào)用一個(gè)函數(shù)(其實(shí)這個(gè)函數(shù)主要作用是給表格中的選擇框加監(jiān)聽(tīng),如果tds沒(méi)有渲染,那監(jiān)聽(tīng)也加不上去)。

<div class="row" id="app">
  <div class="col-sm-12 col-md-12 main">
   <table class="table table-bordered table-striped">
    <thead>
    <tr>
     <th><input type="checkbox" id="checkAll" name="checkAll" /></th>
     <th>日期</th>
     <th>任務(wù)</th>
     <th>是否執(zhí)行</th>
     <th>執(zhí)行結(jié)果</th>
     <th>影響行數(shù)</th>
     <th>執(zhí)行時(shí)間</th>
     <th>執(zhí)行時(shí)長(zhǎng)</th>
     <th>成功率</th>
     <th>操作</th>
    </tr>
    </thead>
    <tbody id="trs">
    <tr v-for="td in tds">
     <td><input type="checkbox" name="checkItem" /></td>
     <td>{{td.date}}</td>
     <td>{{td.job}}</td>
     <td>{{td.is_done==0?'未執(zhí)行':'已執(zhí)行'}}</td>
     <td>{{td.is_success==0?'成功':(td.is_success==1?'失敗':'')}}</td>
     <td>{{td.nums}}</td>
     <td>{{td.begintime}}</td>
     <td>{{td.usedtime}}</td>
     <td>{{td.rate}}</td>
     <td v-if="td.is_done==0">
     </td>
     <td v-if="td.is_done==1">
      <button v-on:click="rerun($index,td.monitor_id)" type="button" class="btn btn-default btn-xs"
        style="padding:1px 10px;margin-top:-3px;margin-bottom:-2px;">重跑
      </button>
     </td>
    </tr>
    </tbody>
   </table>
  </div>
  <!--/.main -->
 </div>

嘗試了

Vue.nextTick(function () {
 alert('new message'); // true
})

無(wú)效,在tds未展示在界面上時(shí)就alert了。

嘗試了

vm.$nextTick(function () {
 alert('new message'); // true
})

也無(wú)效,在tds未展示在界面上時(shí)就alert了。

最后解決辦法是增加一個(gè)vm.$watch('tds',function(val){ })函數(shù),在vm改變后調(diào)用nextTick,最終可以在tds展示在界面之后調(diào)用我想要的函數(shù)。

var vm = new Vue({
  el: '#app',
  ready: function () {
   $.getJSON("/main/getMonitor", {"beginDate": getTheDate(-2), "endDate": getTheDate(0)}, function (result) {
    vm.$set('tds', result);
   });
  },
  data: {
   start: getTheDate(-2),
   end: getTheDate(0),
   isupdate: 0
  },
// computed: {
// // 一個(gè)計(jì)算屬性的 getter
// tds: function () {
//  var myr="";
//  $.getJSON("/main/getMonitor", {"beginDate": getTheDate(-2),"endDate": getTheDate(0)}, function (result) {
//  myr= result;
//  });
//  return myr;
// }
// },
  methods: {
   rerun: function (index, monitor_id) {
    var button = $('#trs').children().eq(index).children().eq(9).children().eq(0);
    button.prop('disabled', true);
    button.html('重跑中<span class="dotting"></span>');
//    $.getJSON("http://m.o2.qq.com/Api/rerunMonitor", {"monitorID": monitor_id}, function (result) {
//     console.log(result);
//     vm.isupdate=(this.isupdate==0?1:0);
//     button.html('重跑');
//     button.prop('disabled', false);
//    });
    $.ajax({
     url: "http://m.o2.qq.com/Api/rerunMonitor",
     // The name of the callback parameter, as specified by the YQL service
     jsonp: "callback",
     // Tell jQuery we're expecting JSONP
     dataType: "jsonp",
     // Tell YQL what we want and that we want JSON
     data: {
      monitorID: monitor_id
     },
     // Work with the response
     success: function (response) {
      console.log(response); // server response
      vm.isupdate = (vm.isupdate == 0 ? 1 : 0);
      button.html('重跑');
      button.prop('disabled', false);
     }
    });
   }
  }
 })
 vm.$watch('start', function (val) {
  $.getJSON("/main/getMonitor", {"beginDate": val, "endDate": this.end}, function (result) {
   vm.tds = result;
  });
 })
 vm.$watch('end', function (val) {
  $.getJSON("/main/getMonitor", {"beginDate": this.start, "endDate": val}, function (result) {
   vm.tds = result;
  });
 })
 vm.$watch('isupdate', function (val) {
  $.getJSON("/main/getMonitor", {"beginDate": this.start, "endDate": this.end}, function (result) {
   vm.tds = result;
  });
 })
 vm.$watch('tds',function(val){
  vm.$nextTick(function() {
   initTableCheckbox();
  });
 })

總結(jié)

以上所述是小編給大家介紹的vuejs實(shí)現(xiàn)ready函數(shù)加載完之后執(zhí)行某個(gè)函數(shù)的方法,希望對(duì)大家有所幫助,如果大家有任何疑問(wèn)請(qǐng)給我留言,小編會(huì)及時(shí)回復(fù)大家的。在此也非常感謝大家對(duì)腳本之家網(wǎng)站的支持!

相關(guān)文章

  • Vue3數(shù)據(jù)更新,頁(yè)面沒(méi)有同步更新的問(wèn)題及解決

    Vue3數(shù)據(jù)更新,頁(yè)面沒(méi)有同步更新的問(wèn)題及解決

    這篇文章主要介紹了Vue3數(shù)據(jù)更新,頁(yè)面沒(méi)有同步更新的問(wèn)題及解決方案,具有很好的參考價(jià)值,希望對(duì)大家有所幫助,如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2024-03-03
  • Vue2仿淘寶實(shí)現(xiàn)省市區(qū)三級(jí)聯(lián)動(dòng)

    Vue2仿淘寶實(shí)現(xiàn)省市區(qū)三級(jí)聯(lián)動(dòng)

    這篇文章主要為大家詳細(xì)介紹了Vue2仿淘寶實(shí)現(xiàn)省市區(qū)三級(jí)聯(lián)動(dòng),文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2017-11-11
  • Vue 使用formData方式向后臺(tái)發(fā)送數(shù)據(jù)的實(shí)現(xiàn)

    Vue 使用formData方式向后臺(tái)發(fā)送數(shù)據(jù)的實(shí)現(xiàn)

    這篇文章主要介紹了Vue 使用formData方式向后臺(tái)發(fā)送數(shù)據(jù)的實(shí)現(xiàn),文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧
    2019-04-04
  • Vue3為什么這么快

    Vue3為什么這么快

    這篇文章主要介紹了Vue3為什么這么快,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧
    2020-09-09
  • Vue3+vuedraggable實(shí)現(xiàn)動(dòng)態(tài)配置頁(yè)面

    Vue3+vuedraggable實(shí)現(xiàn)動(dòng)態(tài)配置頁(yè)面

    這篇文章主要為大家詳細(xì)介紹了Vue3如何利用vuedraggable實(shí)現(xiàn)動(dòng)態(tài)配置頁(yè)面,文中的示例代碼講解詳細(xì),具有一定的借鑒價(jià)值,需要的可以參考一下
    2023-12-12
  • vue中eventbus被多次觸發(fā)以及踩過(guò)的坑

    vue中eventbus被多次觸發(fā)以及踩過(guò)的坑

    這篇文章主要介紹了vue中eventbus被多次觸發(fā)以及踩過(guò)的坑,小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧
    2017-12-12
  • vue-devtools安裝使用全過(guò)程

    vue-devtools安裝使用全過(guò)程

    這篇文章主要介紹了vue-devtools安裝使用方式,具有很好的參考價(jià)值,希望對(duì)大家有所幫助,如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2023-11-11
  • 利用Vue+intro.js實(shí)現(xiàn)頁(yè)面新手引導(dǎo)流程功能

    利用Vue+intro.js實(shí)現(xiàn)頁(yè)面新手引導(dǎo)流程功能

    在同學(xué)們使用某些網(wǎng)站的新版本頁(yè)面的時(shí)候,經(jīng)常會(huì)出現(xiàn)一個(gè)類(lèi)似于新手引導(dǎo)一樣的效果,來(lái)幫助同學(xué)們更好的熟悉新版本頁(yè)面的功能和使用,這篇文章主要給大家介紹了關(guān)于如何利用Vue+intro.js實(shí)現(xiàn)頁(yè)面新手引導(dǎo)流程功能的相關(guān)資料,需要的朋友可以參考下
    2023-11-11
  • vue中的面包屑導(dǎo)航組件實(shí)例代碼

    vue中的面包屑導(dǎo)航組件實(shí)例代碼

    這篇文章主要介紹了vue的面包屑導(dǎo)航組件,本文通過(guò)實(shí)例代碼給大家介紹的非常詳細(xì),具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2019-07-07
  • vue之el-form表單校驗(yàn)以及常用正則詳解

    vue之el-form表單校驗(yàn)以及常用正則詳解

    這篇文章主要介紹了vue之el-form表單校驗(yàn)以及常用正則,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2023-05-05

最新評(píng)論