frontend/examking-app/plugins/uview-ui/components/u-switch/u-switch.vue

(开头部分) 4KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

<template>
	<view class="u-switch" :class="[value == true ? 'u-switch--on' : '', disabled ? 'u-switch--disabled' : '']" @tap="onClick"
	 :style="[switchStyle]">
		<view class="u-switch__node node-class" :style="{
			width: $u.addUnit(this.size),
			height: $u.addUnit(this.size)
		}">
			<u-loading :show="loading" class="u-switch__loading" :size="size * 0.6" :color="loadingColor" />
		</view>
	</view>
</template>

<script>
	/**
	 * switch 开关选择器
	 * @description 选择开关一般用于只有两个选择,且只能选其一的场景。
	 * @tutorial https://www.uviewui.com/components/switch.html
	 * @property {Boolean} loading 是否处于加载中(默认false)
	 * @property {Boolean} disabled 是否禁用(默认false)
	 * @property {String Number} size 开关尺寸,单位rpx(默认50)
	 * @property {String} active-color 打开时的背景色(默认#2979ff)
	 * @property {Boolean} inactive-color 关闭时的背景色(默认#ffffff)
	 * @property {Boolean | Number | String} active-value 打开选择器时通过change事件发出的值(默认true)
	 * @property {Boolean | Number | String} inactive-value 关闭选择器时通过change事件发出的值(默认false)
	 * @event {Function} change 在switch打开或关闭时触发
	 * @example <u-switch v-model="checked" active-color="red" inactive-color="#eee"></u-switch>
	 */
	export default {
		name: "u-switch",
		props: {
			// 是否为加载中状态
			loading: {
				type: Boolean,
				default: false
			},
			// 是否为禁用装填
			disabled: {
				type: Boolean,
				default: false
			},
			// 开关尺寸,单位rpx
			size: {
				type: [Number, String],
				default: 50
			},
			// 打开时的背景颜色
			activeColor: {
				type: String,
				default: '#2979ff'
			},
			// 关闭时的背景颜色
			inactiveColor: {
				type: String,
				default: '#ffffff'
			},
			// 通过v-model双向绑定的值
			value: {
				type: Boolean,
				default: false
			},
后面还有 103 行代码,解锁后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明

AI 解读 AI

登录后可用,每次 10 算力,解读结果公开显示在下面。

还没有人解读过这个文件。