发表更新1 分钟读完 (大约161个字)
vue-vuerouter-basic
VueRouter Basic
一个vuerouter的例子,这里引入了vue,vue-router,app.js需要自己编写
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
| <!DOCTYPE <!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <title>basic</title> <meta name="viewport" content="width=device-width, initial-scale=1"> <script src="../vue.min.js"></script> <script src="../vue-router.min.js"></script> </head> <body> <div id="app"></div> </body> <script src="app.js"></script> </html>
|
app.js
文件内容
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
| const Home = { template: `<div>home</div>` } const Foo = { template: '<div>foo</div>' } const Bar = { template: `<div>bar</div>` } const Unicoede = { template: `<div>unicode</div>`
}
const router = new VueRouter({ routes: [ { path: "/", component: Home }, { path: "/foo", component: Foo }, { path: "/bar", component: Bar }, { path: '/é', component: Unicoede } ] });
new Vue({ router, template: ` <div id="app-content"> <h1>Basic</h1> <ul> <li> <router-link to="/">/</router-link> </li> <li> <router-link to="/foo">/foo</router-link> </li>
<li> <router-link to="/bar">/bar</router-link> </li> <!-- router-link 可以渲染成其他的组件,这里就渲染成了li,虽然中间包裹的 <a> 标签指向 /bar, 但实际运行时 依然是连接到foo-->
<router-link tag="li" to="/foo" :event="['mousedown','touchstart']"> <a>/bar</a> </router-link> </ul> <router-view class="view"></router-view> </div> ` }).$mount('#app');
|
You need to set install_url
to use ShareThis. Please set it in _config.yml
.