vue单页面程序

vue

举个栗子:

<!DOCTYPE html>

<html>

<head>

<meta charset="UTF-8">

<title></title>

<script src="js/vue-router.js" type="text/javascript" charset="utf-8"></script>

<script src="js/vue.js" type="text/javascript" charset="utf-8"></script>

<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />

</head>

<body>

<div >

<a class="list-group-item" v-link="{ path: '/home'}">Home</a>

<a class="list-group-item" v-link="{ path: '/about'}">About</a>

<router-view></router-view>

</div>

<template >

<h1>

我是home

</h1>

</template>

<template >

<h1>

我是about

</h1>

</template>

<script type="text/javascript">

//声明使用路由

Vue.use(VueRouter);

var home = Vue.extend({

template: "#home"

})

var about = Vue.extend({

template: "#about"

})

//创建路由

var router = new VueRouter();

//映射路径

router.map({

'/home':{component:home},

'/about':{component:about}

})

//启动路由

var app = Vue.extend({});

router.start(app,"#app");

</script>

</body>

</html>


转自:http://www.cnblogs.com/lily1010/p/5913503.html

以上是 vue单页面程序 的全部内容, 来源链接: utcz.com/z/376601.html

回到顶部