下面展示一些 component :is
。
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title></title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/animate.css/3.7.2/animate.min.css">
<style>
body{
background-color: #DEE9FA;
}
.active{
color: firebrick;
}
</style>
<script src="js/vue.js" type="text/javascript" charset="utf-8"></script>
</head>
<body>
<div id="app">
<div>
<ul>
<li :class="{active:showname=='one'}" @click="showname='one'">1</li>
<li :class="{active:showname=='two'}" @click="showname='two'">2</li>
<li :class="{active:showname=='three'}" @click="showname='three'">3</li>
</ul>
</div>
<div>
<transition
enter-active-class="animated fadeInDown" mode=" in-out">
<component :is="showname"></component>
</transition>
</div>
</div>
<template id="one">
<div>
<div>one</div>
<div>onething</div>
</div>
</template>
<template id="two">
<div>
<div>two</div>
<div>twothing</div>
</div>
</template>
<template id="three">
<div>
<div>three</div>
<div>threething</div>
</div>
</template>
</body>
<script type="text/javascript">
var vm=new Vue({
el:"#app",
data(){
return {
showname:'one'
}
},
methods:{
},
components:{
'one':{
template:'#one'
},
'two':{
template:'#two'
},
'three':{
template:'#three'
}
}
})
</script>
</html>