国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > JavaScript > 正文

Vue.js第二天學習筆記(vue-router)

2019-11-19 18:44:09
字體:
來源:轉載
供稿:網友

vue中vue-router的使用:

main.js如何配置(es6的寫法):在引用之前記得先   npm 下所需要的vue

import Vue from 'vue'import App from './App.vue'import Router from 'vue-router'import Resource from 'vue-resource'//import VueTouch from 'vue-touch'var VueTouch = require('vue-touch')//引入home頁面import homepage from './page/home.vue'//引入test頁面import test from './page/test.vue'Vue.use(Router);Vue.use(Resource);Vue.use(VueTouch);var router = new Router({ abstract: true, hashbang: false});//實現頁面跳轉router.map({ '/home':{ component:homepage },  '/test':{ component:test },  })router.start(App, '#app')// router.go('test'); 默認直接跳轉到 test 頁面

index.html中引入app.vue和build.js

<!DOCTYPE html><html><head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>vue.js學習筆記(2)</title> <link rel="stylesheet" type="text/css" href="style/bootstrap.css"></head><body> <!--此處注意加載順序,需要先加載dom在加載js,否則會'Cannot find element: #app'--> <div id='app'></div> <script src="static/build.js"></script></body></html><style>body {}</style>

app.vue引入router

<template><div class='all-container'> <div class="public-content">我是公共頁面</div> <div class='menu'> <ul class="list"> <li><a v-link='"/home"'>home頁面</a></li> <li><a v-link='"/test"'>test頁面</a></li> </ul> </div> <router-view transition='animation' class='container' keep-alive></router-view></div></template>

home.vue

<template><div class="home"> <div class="htmleaf-content"> 我是home頁面的內容 </div></div></template>

test.vue

<template><div class="test"> <div class="test-content">我是test頁面的內容</div></div></template>

 最后用webpack 將程序打包.關于webpack大家可以看看

Vue.js――60分鐘webpack項目模板快速入門

webpack主頁

本文已被整理到了《Vue.js前端組件學習教程》,歡迎大家學習閱讀。

以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持武林網。

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 河曲县| 光泽县| 建阳市| 乌海市| 光泽县| 松原市| 湘西| 宽城| 玛沁县| 平远县| 泸定县| 新蔡县| 若羌县| 石楼县| 宜兰市| 荃湾区| 紫阳县| 文登市| 满城县| 江口县| 贵港市| 广德县| 云浮市| 清苑县| 阿鲁科尔沁旗| 平武县| 定州市| 合川市| 临夏市| 高碑店市| 宣城市| 乌鲁木齐市| 江达县| 年辖:市辖区| 阿拉善右旗| 福州市| 文成县| 合江县| 顺义区| 天镇县| 肇州县|