1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 |
- module.exports = {
- data() {
- return {}
- },
- onLoad() {
-
- this.$t.getRect = this._tGetRect
- },
- beforeDestory() {
-
-
- if (this.parent && uni.$t.test.array(this.parent.children)) {
-
- const childrenList = this.parent.children
- childrenList.map((child, index) => {
-
- if (child === this) {
- childrenList.splice(index, 1)
- }
- })
- }
- },
- methods: {
-
- _tGetRect(selector, all) {
- return new Promise((resolve) => {
- uni.createSelectorQuery()
- .in(this)[all ? 'selectAll' : 'select'](selector)
- .boundingClientRect(rect => {
- if (all && Array.isArray(rect) && rect.length) {
- resolve(rect)
- }
- if (!all && rect) {
- resolve(rect)
- }
- })
- .exec()
- })
- },
-
- getParentData(parentName = '') {
-
- if (!this.parent) this.parent = false
-
-
-
- this.parent = this.$t.$parent.call(this, parentName)
- if (this.parent) {
-
- Object.keys(this.parentData).map(key => {
- this.parentData[key] = this.parent[key]
- })
- }
- },
-
- preventEvent(e) {
- e && e.stopPropagation && e.stopPropagation()
- }
- }
- }
|