乡下人产国偷v产偷v自拍,国产午夜片在线观看,婷婷成人亚洲综合国产麻豆,久久综合给合久久狠狠狠9

  • <output id="e9wm2"></output>
    <s id="e9wm2"><nobr id="e9wm2"><ins id="e9wm2"></ins></nobr></s>

    • 分享

      [javascript] cdn模式下vue和vue-router實(shí)現(xiàn)路由

       Coder編程 2021-09-18

      案例大部分都是用npm模式的,現(xiàn)在這個(gè)是使用cdn模式的更符合后端開發(fā)

       

      html部分 , 注意template標(biāo)簽 ,定義上的id

          <script src="https://cdn./npm/vue/dist/vue.js"></script>
          <script src="https://cdn./npm/vue-router/dist/vue-router.js"></script>
      
          <script src="https://cdn./npm/jquery/dist/jquery.min.js"</script>
      
      
      </head>
      <body>
      <div id="app" class="chatKfPageApp">
          <router-view></router-view>
      </div>
      <template id="chatKfIndex">
      <div>111</div>
      </template>
      <template id="chatBox">
          <div>222</div>
      </template>
      </body>
      
      <script src="/static/js/chat-kf-page.js?v=0.1.1"></script>
      </html>
      

      js部分 , 注意每個(gè)template對(duì)應(yīng)一個(gè)組件 , 子template可以繼承父級(jí)的data變量 , 跳轉(zhuǎn)的時(shí)候可以帶著參數(shù) , 獲取到參數(shù)

      //首頁組件
      var chatKfIndex = {
          data: function(){
              return {
                  visitors: {},
              }
          },
          methods: {
          },
          created: function () {
          },
          template:$("#chatKfIndex").html()
      };
      //詳情組件
      var chatKfBox = {
          data: function(){
              return {
                  msgList: [],
                  messageContent: "",
                  face: [],
              }
          },
          methods: {
              init(){
                  alert(this.$parent.socket);
                  alert(this.$route.params.visitorId);
              },
          },
          created: function () {
              this.init();
          },
          template:$("#chatBox").html()
      };
      var routes = [
          { path: '/',component:chatKfIndex}, // 這個(gè)表示會(huì)默認(rèn)渲染
          {path:'/chatKfBox/:visitorId',component:chatKfBox},
      ];
      var router = new VueRouter({
          routes: routes
      })
      
      new Vue({
          router,
          el: '#app',
          data: function(){
              return{
                  socket:null,
              }
          },
          created: function () {
              this.socket=3;
          },
      })

       

        

       

        本站是提供個(gè)人知識(shí)管理的網(wǎng)絡(luò)存儲(chǔ)空間,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點(diǎn)。請(qǐng)注意甄別內(nèi)容中的聯(lián)系方式、誘導(dǎo)購(gòu)買等信息,謹(jǐn)防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請(qǐng)點(diǎn)擊一鍵舉報(bào)。
        轉(zhuǎn)藏 分享 獻(xiàn)花(0

        0條評(píng)論

        發(fā)表

        請(qǐng)遵守用戶 評(píng)論公約