var vue = new Vue({ el:'#demo', data: { sum:0, show:false }, methods: { toggle: function () { var _self=this _self.sum = parseInt(Math.random()*100 + 1) _self.show = true console.log(_self.recommend) setTimeout(function () { _self.show = false },3000) } }, computed: { recommend: function () { return '共有' + this.$data.sum + '条推荐' } }, compiled: function () { /* var _self = this setInterval(function() { _self.sum = parseInt(Math.random()*100 + 1) }, 3000) */ } })