12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697 |
- <template>
- <view
- class="u-row"
- ref="u-row"
- :style="[rowStyle]"
- @tap="clickHandler"
- >
- <slot />
- </view>
- </template>
- <script>
-
- const dom = uni.requireNativePlugin('dom')
-
- import { props } from './props';
- import { mpMixin } from '../../libs/mixin/mpMixin';
- import { mixin } from '../../libs/mixin/mixin';
- import { addUnit, addStyle, deepMerge, sleep } from '../../libs/function/index';
-
- export default {
- name: "u-row",
- mixins: [mpMixin, mixin, props],
- data() {
- return {
-
- }
- },
- computed: {
- uJustify() {
- if (this.justify == 'end' || this.justify == 'start') return 'flex-' + this.justify
- else if (this.justify == 'around' || this.justify == 'between') return 'space-' + this.justify
- else return this.justify
- },
- uAlignItem() {
- if (this.align == 'top') return 'flex-start'
- if (this.align == 'bottom') return 'flex-end'
- else return this.align
- },
- rowStyle() {
- const style = {
- alignItems: this.uAlignItem,
- justifyContent: this.uJustify
- }
-
- if(this.gutter) {
- style.marginLeft = addUnit(-Number(this.gutter)/2)
- style.marginRight = addUnit(-Number(this.gutter)/2)
- }
- return deepMerge(style, addStyle(this.customStyle))
- }
- },
- emits: ["click"],
- methods: {
- clickHandler(e) {
- this.$emit('click')
- },
- async getComponentWidth() {
-
- await sleep()
- return new Promise(resolve => {
-
-
- this.$uGetRect('.u-row').then(res => {
- resolve(res.width)
- })
-
-
-
- dom.getComponentRect(this.$refs['u-row'], (res) => {
- resolve(res.size.width)
- })
-
- })
- },
- }
- }
- </script>
- <style lang="scss" scoped>
- @import "../../libs/css/components.scss";
-
- .u-row {
- @include flex;
- }
- </style>
|