【20】vue.js — slot占位符
来源:互联网 发布:根域名服务器分布 编辑:程序博客网 时间:2024/06/05 01:15
默认情况下我们使用组件会将组件标签内的内容给替换掉,不会显示组件内的内容
<!DOCTYPE html><html lang="en"> <head> <meta charset="UTF-8"> <title>Document</title> <script src="js/vue.js"></script> <style> </style> </head> <body> <div id="box"> <aaa> <ul> <li>1111</li> <li>2222</li> <li>3333</li> </ul> </aaa> </div> <script> var vm=new Vue({ el:'#box', data:{ a:'aaa' }, components:{ 'aaa':{ template:'<h1>xxxx</h1>' } } }); </script> </body></html>
使用slot来占位
<!DOCTYPE html><html> <head> <meta charset="UTF-8"> <title></title> <script type="text/javascript" src="js/vue.js" ></script> </head> <body> <div id="box"> <aaa> <ul> <li>111</li> <li>222</li> <li>333</li> </ul> </aaa> <hr /> <aaa></aaa> </div> <template id="aaa"> <h1>我是模板一</h1> <slot>这是默认的情况</slot> <p>welcome vue</p> </template> </body> <script> var vm = new Vue({ el: '#box', components: { 'aaa': { template: '#aaa' } } }); </script></html>
有区分的替换占位
<!DOCTYPE html><html> <head> <meta charset="UTF-8"> <title></title> <script type="text/javascript" src="js/vue.js" ></script> </head> <body> <div id="box"> <aaa> <ul slot="ul-slot"> <li>111</li> <li>222</li> <li>333</li> </ul> <ol slot="ol-slot"> <li>aaa</li> <li>bbb</li> <li>ccc</li> </ol> </aaa> <hr /> <aaa></aaa> </div> <template id="aaa"> <h1>我是模板一</h1> <slot name="ul-slot">ul替换占位符</slot> <slot name="ol-slot">ol替换占位符</slot> <p>welcome vue</p> </template> </body> <script> var vm = new Vue({ el: '#box', components: { 'aaa': { template: '#aaa' } } }); </script></html>
阅读全文
0 0
- 【20】vue.js — slot占位符
- Vue.js组件——slot杂记
- vue.js之slot
- vue.js中使用slot
- vue.js中使用slot
- 例子讲解Vue.js的slot分发
- vue组件——slot分发内容
- Vue——Slot(插槽)
- vue踩坑系列——slot
- Vue.js的组件(五)分发 之 单个Slot
- Vue.js的组件(六)分发 之 具名Slot
- Vue Slot用法
- vue笔记--------slot
- Vue组件中的slot
- vue里面的slot
- vue slot内容分发
- vue slot 内容分发
- vue slot插槽
- Vim插入相关的命令介绍
- TwoSum两个数的和
- ComBo Select可检索下拉框的使用
- 高性能消息队列 CKafka 核心原理介绍(上)
- 计算机网络基础 1.0 -- 概述
- 【20】vue.js — slot占位符
- 基于对so中的函数加密技术实现so加固
- DataSource没有getconnection方法
- 规律数字方阵
- 完美解决VedioView加载视屏黑一下的问题
- 使用sqlite3解决SVN不能cleanUp的问题
- 内核---从Linux内核源码结构纵览内核
- MySQL-MHA 搭建文档
- nf_hook_ops 钩子的注册