vue动态组价实例
来源:互联网 发布:武汉网络施工队 编辑:程序博客网 时间:2024/05/18 17:01
自学vue,其中最懵的就是没有实例,下面是vue中动态组件的简单实例,希望对菜鸟的我们有所帮助。
<!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8"> <title>动态组件</title> <script src="vue.js"></script></head><body><div id="app"><component v-bind:is="currentView"></component> <!--component不是固定的元素,可以更换元素,动态地绑定到它的 is 特性,我们让多个组件可以使用同一个挂载点,并动态切换:--><button v-on:click="currentfn(n++)">点击</button></div><script> var app=new Vue({ el:'#app', data:{ currentView:'home',//currentView是固定的属性,不能改变。 n:1 }, components:{ home:{template:'<h1>我是home</h1>'}, posts:{template:'<h2>我是posts</h2>'}, archive:{template:'<h3>我是archive</h3>'} }, methods:{ currentfn:function (n) { if(n<2){ this.currentView =['home','posts','archive'][n] }else{ app.n=0; this.currentView =['home','posts','archive'][n] } } } })</script></body></html>
不明白的,可以对照官网上的解释来看会更清晰一点。
阅读全文
1 0
- vue动态组价实例
- vue动态路由匹配实例
- 绑定 value 到 Vue 实例的一个动态属性上
- vue实例
- Vue实例
- vue实例
- Vue实例
- vue 实例
- Vue实例
- Vue 实例
- Vue实例
- Vue 实例
- vue ——Vue实例
- Vue基础之Vue实例
- Vue基础(vue实例)
- vue.js入门实例
- vue-router简单实例
- Vue.js 实例
- 高并发情况下 如何支撑大量的请求
- ssh,json,easyui,ajax前后台交互(只提供主要代码)
- 上传图片,如何从tomcat下转存到项目上
- lavarel的密码验证
- vim常用的命令
- vue动态组价实例
- https三次握手 4次断开
- 【Eternallyc】NEFU-118-n!后面有多少个0
- systemUI学习
- 基于SSM的RBAC权限系统(1)-利用ajax,bootstrap,ztree完成权限树功能
- Spire.Doc 教程:在C#,VB.NET创建、编辑和保存Word
- abaqus分析步
- CodeForces
- OpenStack组件Swift单机搭建