Component({ options: { addGlobalClass: true, multipleSlots: true }, properties: { content: { type: String, value: '' } }, data: { foldble: true, unfold: true }, observers: { 'content': function () { this.setContent() } }, methods: { setContent: function () { var query = this.createSelectorQuery() var that = this query.select('#content').boundingClientRect() query.select('#frame').boundingClientRect() query.exec(function (res) { if (res[0] && res[0].height) { if (res[0].height > res[1].height) { that.setData({ foldble: true }) } else { that.setData({ foldble: null }) } } }) }, unfoldText: function(){ this.setData({ unfold: !this.data.unfold }) } } })