当前位置: 首页 > news >正文

VUE自动定义控件SwitchButton

 

 

<switch-button style="margin-left: 20rpx;" :buttons='["一键打分", "快捷打分"]' select="快捷打分" @ButtonClick="SwitchButnClick"></switch-button>

 SwitchButton.vue

<template><view class="DivLine"><text v-for="(button, index) in buttons" v-bind:class="{'select': curSelect===button }" @click="buttonClick(button, index)">{{button}}</text></view>
</template><script>export default {name: 'SwitchButton',props: {buttons: Array,select: String},data() {return {init: false,curSelect: this.select,msg: '',menus: ["按钮1", "按钮2", "按钮3"]}},created() {// this.showTittle = this.curTittle;	// 创建时属性curTittle为空},computed: {// showTittle2()// {// 	this.showTittle = this.curTittle;	// curTittle每次变动时,均会调用showTittle2// 	return this.showTittle;// }},watch: {curTittle: function(val) {// this.showTittle = val;				// 仅仅变动时调用},},mounted() {//this.select = this.curTittle;			// 在watch之后仅仅执行一次},methods: {ClickIteam(index) {this.buttonClick(this.buttons[index], index);},buttonClick(item, index) {if(item != this.curSelect){this.curSelect = item;this.$emit('ButtonClick', item, index);}}// menuClick(path){//   headerDiv.forEach(element => {//     element.tittle = "选中";//     if(element.path == path) element.selected = true;//     else element.selected = false;//   });// }}}
</script><style scoped>.Content {position: relative;text-align: left;display: inline-block;width: 100%; // 显示屏幕宽度overflow: auto; // 超出宽度自动滚动/* 高度未限制,则随内容加长 */background-color: gray;vertical-align: middle;border-bottom: 1px solid #ccc;padding: 4px 0px 4px 0px;}/* 已最大长度/最大宽度展示一行 */.DivLine {height: max-content;width: max-content; // 随内容自动加宽display: inline-block;text-align: center;border: 1px solid rgb(126, 125, 125);background: #f1f1f1;padding: 2px;border-radius: 5px;}text {/* background-color: #ebebeb; *//* color: #007AFF;border-bottom: 2rpx solid #007AFF; *//* box-shadow: 0 0 5px 0px rgb(126, 125, 125); */width: max-content;height: 20px;line-height: 20px;font-size: 16px;background-color: #fff;color: #007AFF;display: block;border-radius: 0px;padding: 5px 10px;margin: 0 auto;display: inline-block;}.select {/* background-color: #ebebeb; */background-color: #007AFF;color: #fff;/* box-shadow: 0 0 5px 0px rgb(126, 125, 125); */}</style>

http://www.xdnf.cn/news/95779.html

相关文章:

  • 【自我介绍前端界面分享】附源码
  • 激光雷达成为新时代「安全气囊」,禾赛推动智能车安全再进化
  • STM32---串口通信USART
  • 开源模型应用落地-语音合成-Spark-TTS-零样本克隆与多语言生成的突破
  • windows中安装VMware Workstation Pro虚拟机和ubuntu
  • 图像预处理-模板匹配
  • 量子计算浪潮下的安全应对之法
  • 论文精读:大规模MIMO波束选择问题的量子计算解决方案
  • 黑马商城-微服务笔记
  • python基础语法测试
  • 欧拉环境(openEuler 22.03 LTS SP3)安装移动磐维数据库(PanWeiDB_V2.0-S2.0.2_B01)步骤
  • kaggle网站使用教程
  • Stream API 对两个 List 进行去重操作
  • python实战项目63:获取腾讯招聘信息内容并进行统计分析
  • 9N60-ASEMI无人机专用功率器件9N60
  • Java进阶--注解与克隆
  • IDEA add gitlab account 提示
  • render props是什么?
  • 【MQ篇】RabbitMQ之发布订阅模式!
  • Hive中Map和Reduce阶段的分工
  • MySQL通用性能优化模板(MySQL General Performance Optimization Template)
  • MyBatis-Plus 使用 Wrapper 构建动态 SQL 有哪些优劣势?
  • 爱普生SG-8200CG可编程晶振成为工业自动化领域的理想选择
  • Tailwind CSS 实战:基于 Kooboo 构建个人博客页面
  • vue3中slot(插槽)的详细使用
  • JVM 生产环境问题定位与解决实战(七):实战篇——OSSClient泄漏引发的FullGC风暴
  • 事业单位体检心电图不合格类型有哪些
  • 视频监控从安装到优化的技术指南,视频汇聚系统EasyCVR智能安防系统构建之道
  • 如何使用 uv 构建 Python 包并本地安装
  • 配色之道:解码产品设计中的UI设计配色艺术