12 |
- "use strict";const n=require("../../common/vendor.js"),r={name:"EvanSwitch",props:{value:{type:[String,Number,Boolean],default:!1},activeColor:{type:String,default:"#108ee9"},inactiveColor:{type:String,default:"#fff"},size:{type:Number,default:30},disabled:{type:Boolean,default:!1},activeValue:{type:[String,Number,Boolean],default:!0},inactiveValue:{type:[String,Number,Boolean],default:!1},beforeChange:{type:Function,default:null},extraData:null,contextLevel:{type:Number,default:1}},computed:{switchHeight(){return this.size+"px"}},watch:{value:{immediate:!0,handler(t){this.currentValue=t}}},data(){return{currentValue:!1}},methods:{toggle(){if(!this.disabled)if(this.beforeChange&&typeof this.beforeChange=="function"){let t=this;for(let e=0;e<this.contextLevel;e++)t=t.$options.parent;const a=this.beforeChange(this.currentValue===this.activeValue?this.inactiveValue:this.activeValue,this.extraData,t);typeof a=="object"?a.then(()=>{this.toggleValue()}).catch(()=>{}):typeof a=="boolean"&&a&&this.toggleValue()}else this.toggleValue()},toggleValue(){this.currentValue=this.currentValue===this.activeValue?this.inactiveValue:this.activeValue,this.$emit("input",this.currentValue),this.$emit("change",this.currentValue)}}};function o(t,a,e,s,i,l){return{a:i.currentValue===e.activeValue?"translateX(29px)":"translateX(0)",b:n.o((...u)=>l.toggle&&l.toggle(...u)),c:e.disabled?1:"",d:i.currentValue===e.activeValue?e.activeColor:e.inactiveColor}}const c=n._export_sfc(r,[["render",o],["__scopeId","data-v-687346f1"]]);wx.createComponent(c);
- //# sourceMappingURL=../../../.sourcemap/mp-weixin/components/evan-switch/evan-switch.js.map
|