123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166 |
- <template>
- <view class="tm-divider ">
- <view class="flex-center tm-divider-wk" :class="[
- vertical?' flex-col flexVer ':'',setpsClass
- ]" >
- <view :style="{
- borderBottomStyle:model,
- height:vertical?height/2+'px':'1rpx',
- width:vertical?'1rpx':'50%',
- }" class="tm-divider-left" :class="[vertical?color_tmeme:`border-${color_tmeme}-b-1`]">
- </view>
- <view v-if="text" :class="[
- vertical?'py-20':'px-20'
- ]" class="tm-divider-text text-size-xs" :style="{color:'grey'}">{{text}}</view>
-
- <text v-if="!text"></text>
- <view :style="{
- borderBottomStyle:model,
- height:vertical?(height/2+'px'):'1rpx',
- width:vertical?'1rpx':'50%',
-
- }" class="tm-divider-right" :class="[vertical?color_tmeme:`border-${color_tmeme}-b-1`]"></view>
- </view>
- </view>
- </template>
- <script>
-
- export default {
- name: "tm-divider",
- props: {
-
- text: {
- type: String,
- default: ''
- },
-
- color: {
- type: String,
- default: 'grey'
- },
-
- height: {
- type: Number,
- default: 100
- },
-
- width: {
- type: Number,
- default: 0
- },
-
- vertical: {
- type: Boolean,
- default: false
- },
-
- model: {
- type: String,
- default: 'solid'
- },
-
- fllowTheme: {
- type: Boolean | String,
- default: false
- }
- },
- computed: {
- wd: {
- get: function() {
- if (this.width) return this.width;
- return this.width_s;
- },
- set: function(val) {
- this.width_s = val;
- }
- },
- color_tmeme: function() {
- if (this.$tm.vx.state().tmVuetify.color !== null && this.$tm.vx.state().tmVuetify.color && this
- .fllowTheme) {
- return this.$tm.vx.state().tmVuetify.color;
- }
- return this.color;
- },
- },
- data() {
- return {
- width_s: 0,
- height_s: 0,
- setpsClass: ''
- };
- },
- async mounted() {
- await this.init();
- },
- methods: {
- async init() {
- this.$nextTick(async function() {
- let tbs = await this.$Querey(".tm-divider");
- this.wd = tbs[0].width ? tbs[0].width : this.wd;
- })
- },
- setWidth(width) {
- this.$nextTick(async function() {
- this.wd = width;
- this.setpsClass = 'setpsClass'
- if (this.text) {
- let tbs_text = await this.$Querey(".tm-divider-text");
-
- this.wd = this.wd - tbs_text[0].width;
- }
- })
- }
- },
- }
- </script>
- <style lang="scss" scoped>
- .tm-divider {
- display: block;
- width: auto;
- position: relative;
- .tm-divider-wk {
- &.setpsClass {
- position: absolute;
- // left: -100upx;
- line-height: 0;
- // left: 0;
- }
- }
- .flexVer {
- width: 1px;
- }
- .tm-divider-text {
- flex-shrink: 0;
- }
- .tm-divider-left,
- .tm-divider-right {
- width: 50%;
- height: 1px;
- border-bottom-width: 1px;
- }
- }
- </style>
|