vue 使用記錄

vue   使用記錄

1.路徑:http://localhost:8081/#/test?name=1    
<router-link :to="{path:'/test',query: {name: id}}">跳轉</router-link>(id是參數)
    使用:this.$route.query.id
2.路徑:http://localhost:8081/#/test/1
    <router-link :to="'/test/'+id">跳轉</router-link>(id是參數)
    {
       path: '/test/:id',
       name: 'Test',
       component: require('./component/Test.vue')
    }
    使用:this.$route.params.id
    this.$route是一個數組,裏面包含路由的所有信息
    
    注意:router-link中鏈接如果是‘/’開始就是從根路由開始,如果開始不帶‘/’,則從當前路由開始
    
3. ## vue 刪除一行數據
   <button v-on:click="doM(id,index)"></button>
   data: {
      todos : [ {},{}]
   }
   methods : {
       doM: function(id,index){
        this.todos.splice(index,1)
       }
   }
   
4.  在 option  選擇框中, value   要綁定屬性,@bind:value  or  :value
1
    <select v-model='somedata.gid'  class="form-control">
        <option value='default'>請選擇類別 ... </option>
        <template  v-for="d in  this.listdata" >
          <option v-if="somedata.gid == d.gidNumber"  :value='somedata.gid' selected > {{ d.cn }} &nbsp;組 </option>
          <option v-else  :value='d.gidNumber'  > {{ d.cn }} &nbsp;組 </option>
        </template>
      </select>


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章