热门
最新
红包
立Flag
投票
同城
我的
发布
CSDN App 扫码分享
评论
2
打赏
- 复制链接
- 举报
下一条:
<!DOCTYPE html><html><head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <title>Document</title> <script src="https://unpkg.com/vue/dist/vue.js"></script> <script src="https://unpkg.com/vue-router/dist/vue-router.js"></script></head><body> <div id="app"> <h1>Hello !</h1> <p> <router-link to="/hash1">切换至com1</router-link> <router-link to="/hash2">切换至com2</router-link> </p> <router-view></router-view> </div></body><script> / const com1 = { template: '<div>路由1</div>' } const com2 = { template: '<div>路由2</div>' } const routes = [ { path: '/hash1', component: com1 }, { path: '/hash2', component: com2 } ] const router = new VueRouter({ routes }) const app = new Vue({ router }).$mount('#app'); </script></html>为什么运行不出来,报错说vue-router没被定义。