首页
零基础教程
分类浏览
编 程
Sentinel
Go语言
C语言
汇编语言
Android
Java工具库
Spring Cloud Alibaba
Spring Cloud
Spring Data
Spring Boot
Spring Batch
JSP/Servlet
Hadoop
Dubbo
J2Cache
Hibernate
OpenJPA
MyBatis
ShardingSphere
Freemarker
Thymeleaf
Activiti
POI
JMail
Log4j
LogBack
Dom4j
XML
RxJava
JasperReport
JUnit
JMock
Apache Commons
HttpComponents
CGLib
WebSocket
ESAPI
设计模式
前 端
CSS/CSS3
HTML5
JavaScript
JQuery
DHTMLX
浏览器
HTML
前端小知识
Vue.js
NodeJS
ECharts
Less
UmiJS
React
Ant Design
Bootstrap
uni-app
JS-XLSX
数据库
SQL
PL/SQL
MySQL
Oracle
Redis
SQLite
MongoDB
Zookeeper
H2
服务器
Podman
Prometheus
Tomcat
JBoss
RocketMQ
Docker
Nginx
RabbitMQ
其 他
程序员
Maven
SVN
Git
UML
Windows
办公软件
Axure
Jenkins
HTTP
macOS
Java
Spring
Linux
AI
代码片段
Get小技能
面试题
开发工具
<html> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Vue</title> <script src="https://www.hxstrive.com/cdn/libs/vue/2.7.16/vue.min.js"></script> <style type="text/css"> html,body { padding:20px; margin:0; width:100%; height:100%; box-sizing: border-box;} #app .condition { width:100%; } .todo_ul { list-style: none; padding: 0; } .todo_ul li { padding: 5px; } .todo_status { background: #F0F0F0; font-size: 12px; padding: 2px 6px; border-radius: 5px; margin-right: 10px; } .todo_status_ok { background:green; color:#FFF; } .btn_active { font-weight: bold; color: green; font-size: 16px; } </style> </head> <body> <div id="app"> <p> <button v-bind:class="{btn_active: currentStyle == ''}" v-on:click="changeStyle('')">默认样式</button> <button v-bind:class="{btn_active: currentStyle == 'style1'}" v-on:click="changeStyle('style1')">样式一</button> <button v-bind:class="{btn_active: currentStyle == 'style2'}" v-on:click="changeStyle('style2')">样式二</button> </p> <p> <input type="text" placeholder="TODO 查询" v-model="condition" /> </p> <!-- TODO 列表 --> <todo-list v-bind:filtered_todos="filteredTodos"> <!-- 自定义样式一 --> <template v-if="currentStyle == 'style1'" v-slot:todo="{ todo }"> <input type="checkbox" v-model="todo.isComplete" /> {{ todo.text }} </template> <!-- 自定义样式二 --> <template v-else-if="currentStyle == 'style2'" v-slot:todo="{ todo }"> <span v-if="todo.isComplete" class="todo_status todo_status_ok">已完成</span> <span v-else class="todo_status">未完成</span> {{ todo.text }} </template> </todo-list> </div> <script type="text/javascript"> Vue.component('todo-list', { props: [ "filtered_todos" ], template: ` <ul> <li v-for="todo in filtered_todos" v-bind:key="todo.id"> <!-- 我们为每个 todo 准备了一个插槽,将 todo 对象作为一个插槽的 prop 传入。--> <slot name="todo" v-bind:todo="todo"> <!-- 默认内容 --> {{ todo.isComplete ? "√" : "-" }} {{ todo.text }} </slot> </li> </ul> ` }); var app = new Vue({ el: "#app", data: { currentStyle: "", condition: "", todoList: [ { id:1, text:"搭建 Vue.js 开发环境", isComplete:true }, { id:2, text:"学习 Vue.js 基础语法", isComplete:true }, { id:3, text:"学习 Vue.js 组件知识", isComplete:false }, { id:4, text:"学习 Vue.js 插槽知识", isComplete:false }, { id:5, text:"学习 Vue.js 工作原理", isComplete:false }, { id:6, text:"利用 Vue.js 实现 ToDO App", isComplete:false } ] }, computed: { filteredTodos: function(){ return this.todoList.filter(item => { return (item.text || "").indexOf(this.condition) != -1; }); } }, methods: { changeStyle: function(style) { this.currentStyle = style; } } }); </script> </body> </html>
在线代码编辑器
代码编辑区
自动执行
运行
选择模板
选择JS库
预览效果
清空
切换主题
字符数: 0
提示: 输入完整的HTML代码,包括<!DOCTYPE>和<html>标签
更多工具
Base64 加密/解密工具
JSON 格式化工具
密码随机生成工具
哈希值计算工具
时间戳转换工具
图片 & Base64 互转
HTTP 客户端
Websocket 客户端
选择模板
取消
选择库和版本
库
版本
文件
取消
已复制到剪贴板
关于
本网站专注于 Java、数据库(MySQL、Oracle)、Linux、软件架构及大数据等多领域技术知识分享。涵盖丰富的原创与精选技术文章,助力技术传播与交流。无论是技术新手渴望入门,还是资深开发者寻求进阶,这里都能为您提供深度见解与实用经验,让复杂编码变得轻松易懂,携手共赴技术提升新高度。如有侵权,请来信告知:hxstrive@outlook.com
链接
免责声明
隐私政策
其他应用
开源镜像网站
公众号
©2018-2020 hxstrive.com 版权所有 ICP证:
蜀ICP备14031461号-2
川公网安备51010802032098