vue路由、v-html v-text v-once v-pre v-clock

路由vue-router
1)是vue的一個核心插件
2)可以根據(jù)不同的url訪問不同的頁面(進行不同頁面的跳轉(zhuǎn))
3)創(chuàng)建單頁面應用[又叫做SPA(SINGLE PAGE APP LICATION)應用]

簡單路由

<div class="box">
            <router-link to="/home">首頁</router-link>
            <router-link to="/bag">用戶頁</router-link>
            <router-view></router-view>
        </div>
        <script type="text/javascript" src="js/vue.js" ></script>
        <script type="text/javascript" src="js/vue-router.js" ></script>
        <script>
            var Home={
                template:`
                    <h1>歡迎來到我的網(wǎng)站</h1>
                `
            }
            var Bag={
                template:`
                    <h1>進入用戶頁面</h1>
                `
            }
            const routes=[
                {path:"/",compontent:Home},
                {path:"/home",component:Home},
                {path:"/bag",component:Bag}
            ]
            const router=new VueRouter({
                routes:routes
            })
            
            new Vue({
                el:".box",
                router:router
            })
        </script>

當點擊是字體點顏色

``css
               <style>
            /*.active{
                color:orange;
            }*/
            .router-link-active{
                color: orange;
            }
        </style>
``html
               <div class="box">
            <router-link to="/home">首頁</router-link>
            <router-link to="/bag">用戶頁</router-link>
            <router-view></router-view>
        </div>
``js
                <script type="text/javascript" src="js/vue.js" ></script>
        <script type="text/javascript" src="js/vue-router.js" ></script>
        <script>
            var Home={
                template:`
                    <h1>歡迎來到我的網(wǎng)站</h1>
                `
            }
            var Bag={
                template:`
                    <h1>進入用戶頁面</h1>
                `
            }
            const routes=[
                {path:"/",compontent:Home},
                {path:"/home",component:Home},
                {path:"/bag",component:Bag}
            ]
            const router=new VueRouter({
                routes:routes,
                /*linkActiveClass:"active"*/
            })
            
            new Vue({
                el:".box",
                router:router
            })
        </script>

路由的嵌套

<div class="box">
            <router-link to="/home">首頁</router-link>
            <router-link to="/bag">用戶頁</router-link>
            <router-view></router-view>
            
        </div>
        <script type="text/javascript" src="js/vue.js" ></script>
        <script type="text/javascript" src="js/vue-router.js" ></script>
        <script>
            var home={
                template:`
                    <h1>歡迎來到我的網(wǎng)站</h1>
                `
            }
            var bag={
                template:`
                   <div>
                        <h1>歡迎來到我的用戶頁</h1>
                        <ul>
                            <li>
                                <router-link to="/bag/zhu">注冊</router-link>
                            </li>
                            <li>
                                <router-link to="/bag/deng">登錄</router-link>
                            </li>
                        </ul>
                        <router-view></router-view>
                    </div> 
                `
            }
            var zhu={
                template:`
                    <h1>歡迎來到我的注冊</h1>
                `
            }
            var deng={
                template:`
                    <h1>歡迎來到我的登錄</h1>
                `
            }
            const routes=[
                {path:'/',component:home},
                {path:"/home",component:home},
                {
                    path:"/bag",
                    component:bag,
                    children:[
                        {path:"zhu",component:zhu},
                        {path:"deng",component:deng}
                    ]
                }
            ]
            const router=new VueRouter({
                routes:routes
            })
            new Vue({
                el:".box",
                router:router
            })
        </script>
不常用的五個標簽

v-html 可以識別標簽
v-text 不識別標簽按文本輸入
v-once 只綁定第一次
v-pre 原樣輸出不對數(shù)據(jù)進行解譯
v-clock 數(shù)據(jù)沒有完全加載之前 加載完v-clock就消失了

<div class="box">
            <input type="text" v-model="msg" />
            <p v-html="msg">{{msg}}</p>
            <h2 v-text="msg">{{msg}}</h2>
            <h4 v-once>{{msg}}</h4>
            <h6 v-pre>{{msg}}</h6>
            <h5 v-cloak>{{msg}}</h5>
        </div>
        <script type="text/javascript" src="js/vue.js" ></script>
        <script>
            new Vue({
                el:".box",
                data:{
                    msg:'hello'
                },
                beforeMount:function(){ 
                  alert('beforeMount')
                }
            })
        </script>
?著作權歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務。

相關閱讀更多精彩內(nèi)容

  • 內(nèi)容 UI組件 開發(fā)框架 實用庫 服務端 輔助工具 應用實例 Demo示例 UI組件 element ★13489...
    秋玄語道閱讀 13,977評論 3 116
  • Android 自定義View的各種姿勢1 Activity的顯示之ViewRootImpl詳解 Activity...
    passiontim閱讀 179,013評論 25 709
  • 原本天真地以為—— 只要能堅強地跨過養(yǎng)娃的第一年, 忍受過分娩痛、開奶痛、腰酸背痛, 整明白怎么給娃洗澡、拍嗝、剪...
    方芳淓閱讀 199評論 0 0
  • 線程池有以下的優(yōu)點: 重用線程池中的線程,避免因為線程的創(chuàng)建和銷毀所帶來的性能上的開銷 能有效控制線程池的最大并發(fā)...
    hiandg閱讀 228評論 0 0
  • 不談過程,只說開始和結果。我們的初戀都開始于純真的中學時代,那是記憶里最美好的一段時間。那一年是02年,那些年的學...
    風逐自由路和遠方閱讀 384評論 0 0

友情鏈接更多精彩內(nèi)容