adicionando router
Showing
| ... | @@ -2,13 +2,23 @@ | ... | @@ -2,13 +2,23 @@ |
| <html lang="en"> | <html lang="en"> | ||
| <head> | <head> | ||
| <meta charset="utf-8"> | <meta charset="utf-8"> | ||
| <title>ntflix-ntlabs</title> | <!--<meta http-equiv="X-UA-Compatible" content="IE=edge"> | ||
| <mate name="viewport" context="width=device-width,initial-scale=1.0"> | |||
| <link real = 'icon' href= "<% = BASE_URL%>faicon."ico"> | |||
| <title>ntflix-ntlabs</title> --> | |||
| </head> | </head> | ||
| <body> | <body> | ||
| <div id="app"></div> | |||
| <script src="/dist/build.js"></script> | <script src="/dist/build.js"></script> | ||
| <!-- <div id="app"></div> --> | |||
| <!--<script src="<https://cdn.jsdelivr.net/npm/[email protected]/dist/vue.js>"></script> --> | |||
| <!--<script src="app.js"></script> --> | |||
| </body> | </body> | ||
| ... | ... |
This diff is collapsed.
| ... | @@ -10,6 +10,8 @@ | ... | @@ -10,6 +10,8 @@ |
| "build": "cross-env NODE_ENV=production webpack --progress --hide-modules" | "build": "cross-env NODE_ENV=production webpack --progress --hide-modules" | ||
| }, | }, | ||
| "dependencies": { | "dependencies": { | ||
| "cli": "^1.0.1", | |||
| "router": "^1.3.7", | |||
| "vue": "^2.5.11" | "vue": "^2.5.11" | ||
| }, | }, | ||
| "browserslist": [ | "browserslist": [ | ||
| ... | @@ -18,6 +20,7 @@ | ... | @@ -18,6 +20,7 @@ |
| "not ie <= 8" | "not ie <= 8" | ||
| ], | ], | ||
| "devDependencies": { | "devDependencies": { | ||
| "@vue/cli-plugin-router": "~5.0.0", | |||
| "babel-core": "^6.26.0", | "babel-core": "^6.26.0", | ||
| "babel-loader": "^7.1.2", | "babel-loader": "^7.1.2", | ||
| "babel-preset-env": "^1.6.0", | "babel-preset-env": "^1.6.0", | ||
| ... | ... |
| <template> | <template> | ||
| <div class= "home"> | |||
| <div id= "app"> | |||
| <router-view> | |||
| <div id="nav"> | |||
| <router-link to="/">Home</router-link> | | |||
| <router-link to="/about">about</router-link> | |||
| <router-link to="/cadastro">cadastro</router-link> | |||
| </div> | |||
| </router-view> | |||
| <div class="Menu-Principal"> | <div class="Menu-Principal"> | ||
| <ul> | <ul> | ||
| <li><a href="#home">Home</a></li> | <li><a href="#home">Home</a></li> | ||
| <li><a href="#news">cadastro</a></li> | <li><a href="#news">cadastro</a></li> | ||
| ... | @@ -472,22 +483,34 @@ | ... | @@ -472,22 +483,34 @@ |
| </div> | </div> | ||
| </template> | </template> | ||
| <script> | |||
| <script src = "https://unpkg.com/vue-router/dist/vue-router.js"></script> | import Home from './components/home.vue' | ||
| <script src = "https://cdn.jsdelivr.net/npm/[email protected]"></script> | import cadastro from './components/cadastro.vue' | ||
| <script src = "https://unpkg.com/vue-router/dist/vue-router.js"></script> | |||
| <script> | |||
| const routes = { | |||
| '/': Home, | |||
| '/cadastro': cadastro | |||
| } | |||
| export default { | export default { | ||
| name: 'app', | data() { | ||
| data () { | return { | ||
| return { | currentPath: window.location.hash | ||
| msg: 'Welcome to Your Vue.js App', | } | ||
| } | }, | ||
| }, | computed: { | ||
| currentView() { | |||
| return routes[this.currentPath.slice(1) || '/'] || NotFound | |||
| } | |||
| }, | |||
| mounted() { | |||
| window.addEventListener('hashchange', () => { | |||
| this.currentPath = window.location.hash | |||
| }) | |||
| } | |||
| } | } | ||
| </script> | </script> | ||
| <style> | <style> | ||
| ... | ... |
src/components/cadastro.vue
0 → 100644
src/components/home.vue
0 → 100644
Please
register
or
sign in
to comment