// components/container-loading/container-loading.js Component({ /** * 组件的属性列表 */ properties: { loadingState: { type: String, value: 'loading' }, widgetHeight: { type: Number, value: 200 } }, observers: { 'loadingState': function (newVal) { this.setData({ loadingVisible: newVal }); }, 'widgetHeight': function (newVal) { this.setData({ height: newVal }) } }, data: { loadingVisible: 'loading', height: 200, localAssets: '' }, lifetimes: { attached() { const app = getApp() this.setData({ localAssets: app.globalData.localAssets }) } }, /** * 组件的方法列表 */ methods: { notifyParentToRefresh() { // 触发自定义事件 'parentRefresh',并可以传递数据(这里传递一个空对象) this.triggerEvent('refresh', {}); }, notifyParentCreate() { this.triggerEvent('create', {}) } } })