var vm = new Vue({ data: { list: [] }, methods: { changeDom: function () { this.$nextTick(function(){ //需要执行的方法 }); } }, watch: { list: function () { this.$nextTick(function(){ //需要执行的方法 }); } } })
如下应用示例(有一个滚动事件,必须要页面渲染完成后才可以执行):
var vue2 = new Vue({ el: "#vueNotice", data: { list: [] }, mounted: function () { this.newlyData(); }, methods: { newlyData() { var self = this; ajaxPureRequest('/sales/GetNewly', 'get', null, false, function (rs) { if (rs.code == "200") { self.list = rs.res.data; if (rs.res.data.length==0) { $("#notice").css("display", "none"); } } }); } }, watch: { list: function () { this.$nextTick(function () { $('#notice').rollSlide({ orientation: 'top', num: 1, v: 2500, isRoll: true }); }) } }, });