UNPKG

vue2-vant2-components

Version:

基于 vue2 和 vant2 开发的移动端表格组件

1 lines 3.49 kB
(function(){"use strict";var t={};!function(){t.d=function(e,l){for(var i in l)t.o(l,i)&&!t.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:l[i]})}}(),function(){t.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)}}(),function(){t.r=function(t){"undefined"!==typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}}();var e={};t.r(e),t.d(e,{default:function(){return u}});var l=function(){var t=this,e=t._self._c;return e("div",{ref:"tabulationCell",staticClass:"vvc-tabulation_cell"},[t._t("default",(function(){return[t.labelWidth||t.$scopedSlots&&t.$scopedSlots.label?e("div",{staticClass:"vvc-tabulation_cell_label",style:{width:`${t.formatWidth(t.labelWidth)}px`,textAlign:t.labelAlign||t.align||t.rootLabelAlign||t.rootAlign}},[t._t("label",(function(){return[t._v(t._s(t.label))]}))],2):t._e(),t.valueWidth||t.$scopedSlots&&t.$scopedSlots.value?e("div",{class:["vvc-tabulation_cell_value",{"is-block":(t.$children||[]).some((t=>t.$refs&&t.$refs.tabulationCell))}],style:{width:`${t.formatWidth(t.valueWidth)}px`,textAlign:t.align||t.rootAlign}},[t._t("value",(function(){return[t._v(t._s(t.value))]}))],2):t._e()]}))],2)},i=[],n={name:"vvcTabulationCell",data(){return{tabulationWidth:0}},inject:["rootAlign","rootLabelAlign"],props:{label:{type:String},value:{type:[String,Number]},labelWidth:{type:[String,Number]},valueWidth:{type:[String,Number]},align:{type:String,validator:t=>["left","right","center"].includes(t)},labelAlign:{type:String,validator:t=>["left","right","center"].includes(t)},relativeRoot:{type:Boolean,default:!0}},mounted(){this.getTabulationWidth()},methods:{formatWidth(t){var e;let l=0;const i=this.getStyleNumber(document.documentElement.style.fontSize),n=this.tabulationWidth,o=(null===(e=this.$el)||void 0===e?void 0:e.parentElement.clientWidth)||0,r=this.getStyleNumber(t),a=t.replace(/[\d\.]/g,"")||"";switch(a){case"rem":l=r*i;break;case"px":case"":l=r;break;case"%":l=Math.floor(r*(this.relativeRoot?n:o)*10)/1e3;break;default:l=t;break}return l},getTabulationWidth(t=this){var e,l;const i=null===(e=t.$parent)||void 0===e||null===(l=e.$refs)||void 0===l?void 0:l.tabulation;let n=0;i?(n=this.getStyleNumber(getComputedStyle(i).width)-this.getStyleNumber(getComputedStyle(i).borderLeftWidth)-this.getStyleNumber(getComputedStyle(i).borderRightWidth)-this.getStyleNumber(getComputedStyle(i).paddingLeft)-this.getStyleNumber(getComputedStyle(i).paddingRight),this.tabulationWidth=n):this.getTabulationWidth(t.$parent)},getStyleNumber(t){const e=Number(t.replace(/[^\d\.]/g,""));return!isNaN(parseFloat(e))&&isFinite(e)?e:0}}},o=n;function r(t,e,l,i,n,o,r,a){var s,u="function"===typeof t?t.options:t;if(e&&(u.render=e,u.staticRenderFns=l,u._compiled=!0),i&&(u.functional=!0),o&&(u._scopeId="data-v-"+o),r?(s=function(t){t=t||this.$vnode&&this.$vnode.ssrContext||this.parent&&this.parent.$vnode&&this.parent.$vnode.ssrContext,t||"undefined"===typeof __VUE_SSR_CONTEXT__||(t=__VUE_SSR_CONTEXT__),n&&n.call(this,t),t&&t._registeredComponents&&t._registeredComponents.add(r)},u._ssrRegister=s):n&&(s=a?function(){n.call(this,(u.functional?this.parent:this).$root.$options.shadowRoot)}:n),s)if(u.functional){u._injectStyles=s;var d=u.render;u.render=function(t,e){return s.call(e),d(t,e)}}else{var c=u.beforeCreate;u.beforeCreate=c?[].concat(c,s):[s]}return{exports:t,options:u}}var a=r(o,l,i,!1,null,null,null),s=a.exports,u=s;module.exports=e})();