日韩av黄I国产麻豆传媒I国产91av视频在线观看I日韩一区二区三区在线看I美女国产在线I麻豆视频国产在线观看I成人黄色短片

歡迎訪問(wèn) 生活随笔!

生活随笔

當(dāng)前位置: 首頁(yè) >

vue组件加载完成之后执行方法_Vue.js实现ready函数加载完之后执行某个函数的方法...

發(fā)布時(shí)間:2023/12/29 37 豆豆
生活随笔 收集整理的這篇文章主要介紹了 vue组件加载完成之后执行方法_Vue.js实现ready函数加载完之后执行某个函数的方法... 小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

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

發(fā)布于 2020-7-10|

復(fù)制鏈接

摘記: vue.js 教程Vue.js(讀音 /vju?/, 類(lèi)似于 view) 是一套構(gòu)建用戶界面的漸進(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)也加不上去)。

```javascript

..

vue.js 教程Vue.js(讀音 /vju?/, 類(lèi)似于 view) 是一套構(gòu)建用戶界面的漸進(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)也加不上去)。

```javascript

日期

任務(wù)

是否執(zhí)行

執(zhí)行結(jié)果

影響行數(shù)

執(zhí)行時(shí)間

執(zhí)行時(shí)長(zhǎng)

成功率

操作

{{td.date}}

{{td.job}}

{{td.is_done==0?'未執(zhí)行':'已執(zhí)行'}}

{{td.is_success==0?'成功':(td.is_success==1?'失敗':'')}}

{{td.nums}}

{{td.begintime}}

{{td.usedtime}}

{{td.rate}}

重跑

```

嘗試了

```javascript

Vue.nextTick(function () {

alert('new message'); // true

})

```

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

```javascript

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ù)。

```javascript

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('重跑中');

// $.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é)

以上是生活随笔為你收集整理的vue组件加载完成之后执行方法_Vue.js实现ready函数加载完之后执行某个函数的方法...的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。

如果覺(jué)得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。