当前位置:网站首页>012_ switch
012_ switch
2022-06-30 01:50:00 【Free and bound javajavascript】
1. Switch switch
1.1. Represents a switch between two opposing states , It's used to trigger 「 open / Turn off 」.
1.2. Switch properties
Parameters | explain | type | The default value is |
value / v-model | Binding value | boolean / string / number | nothing |
disabled | Whether to disable | boolean | false |
width | switch Width ( Pixels ) | number | 40 |
active-icon-class | switch The class name of the icon displayed when opened , Setting this option will ignore active-text | string | nothing |
inactive-icon-class | switch The class name of the icon displayed when closing , Setting this option will ignore inactive-text | string | nothing |
active-text | switch Text description when opening | string | nothing |
inactive-text | switch Text description when closing | string | nothing |
active-value | switch On the value of | boolean / string / number | true |
inactive-value | switch The value at the time of closing | boolean / string / number | false |
active-color | switch The background color when opened | string | #409EFF |
inactive-color | switch Background color when off | string | #C0CCDA |
name | switch Corresponding name attribute | string | nothing |
validate-event | change switch Whether to trigger the verification of the form in the status | boolean | true |
1.3. Switch events
Event name | explain | Callback Arguments |
change | switch Callback function when state changes | The value of the new state |
2. Switch Switch example
2.1. Use the scaffold to create a new one named element-ui-switch Front end projects , At the same time to install Element plug-in unit .

2.2. To write App.vue
<template>
<div id="app">
<h1> Basic usage </h1>
<el-switch v-model="base_value" active-color="#13ce66" inactive-color="#ff4949"></el-switch>
<h1> A word description </h1>
<el-switch v-model="text_value1" active-text=" Pay by month " inactive-text=" Pay per year " @change="handleChange"></el-switch>
<el-switch style="display: block" v-model="text_value2" active-color="#13ce66" inactive-color="#ff4949" active-text=" Pay by month " inactive-text=" Pay per year "></el-switch>
<h1> Extended value type </h1>
<el-tooltip :content="'Switch value: ' + ext_value" placement="top">
<el-switch v-model="ext_value" active-color="#13ce66" inactive-color="#ff4949" active-value="100" inactive-value="0"></el-switch>
</el-tooltip>
<h1> Disabled state </h1>
<el-switch v-model="disabled_value1" disabled></el-switch>
<el-switch v-model="disabled_value2" disabled></el-switch>
</div>
</template>
<script>
export default {
data () {
return {
base_value: true,
text_value1: true,
text_value2: true,
ext_value: '100',
disabled_value1: true,
disabled_value2: false
}
},
methods: {
handleChange (val) {
console.log(val)
}
}
}
</script>
2.3. Run the project

边栏推荐
- Is the processor the main factor in buying a mobile phone?
- DTW learning (dynamic time warping) -- Thought and code implementation
- How to deal with occasional bugs?
- Varnish 基础概览3
- cookie加密11
- Pytorch模型训练到哪里找预训练模型?
- 【机器学习Q&A】准确率、精确率、召回率、ROC和AUC
- 【二叉树】最大二叉树 II
- Varnish 基础概览5
- [graph neural network] summary of graph classification study [3]: evaluation of graph classification methods and future research directions
猜你喜欢
随机推荐
Understand AQS principle (flow chart and synchronous queue diagram)
Mysql 监控1
Kubernetes core object overview details
Is the processor the main factor in buying a mobile phone?
画画水族馆的应用特色及功能
Cookie加密15 登录加密
C语言 我要通过
A summary of the quantification of deep network model
C语言 写出这个数
MySQL monitoring 6
Varnish 基础概览3
【机器学习Q&A】数据抽样和模型验证方法、超参数调优以及过拟合和欠拟合问题
Varnish foundation overview 3
The national industrial information security development research center issued the report on industrial information security situation in 2021
Cookie加密10
What should be paid attention to in the design and production of the Urban Planning Museum
Scala基础【入门及安装】
Three questions from the boss
Conjecture of prime pairs in C language
Varnish foundation overview 8
![【图神经网络】图分类学习研究综述[3]:图分类方法评价及未来研究方向](/img/b1/2afa73a14b2f41b7a65c4c2d261e6a.png)








