亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

Vue 頁面跳轉(zhuǎn)不用router-link的實(shí)現(xiàn)代碼

 更新時間:2018年04月12日 09:11:31   作者:Oliver556  
這篇文章主要介紹了 Vue 頁面跳轉(zhuǎn)不用router-link的實(shí)現(xiàn)代碼,文中給大家介紹了vue router-link跳轉(zhuǎn)傳值示例,需要的朋友可以參考下

1、給父頁面跳轉(zhuǎn)的地方設(shè)置事件

//原來的頁面上展示的信息 
 <div v-if="!addShow" class="function"> 
 <el-row> 
  <template slot-scope="scope"> 
   <el-button type="success" size="mini" @click="handleEdit(scope.$index, scope.row)">編輯</el-button>  
    //帶參數(shù)進(jìn)行編輯 
   <el-button type="danger" size="mini" @click="handleDelete(scope.row)">刪除</el-button> 
  </template> 
 </el-row> 
</div> 

//要跳轉(zhuǎn)過去的頁面用隱藏來代替 
    <div v-if="addShow" class="add-category "> 
     <el-col :span="20" :offset="2"> 
      <el-form :model="formData" :rules="rules" ref="formData" label-position="left"> 
       <el-row> 
        <el-col :span="10"> 
         <el-form-item label="銷售區(qū)域名稱" prop="name"> 
          <el-input v-model="formData.name"></el-input>  
            //v-model綁定formData.name(name為需要的字段,formDataw為表格ref綁定的數(shù)據(jù)) 
         </el-form-item> 
        </el-col> 
       </el-row> 
       <el-col :span="18"> 
        <el-form-item label="銷售區(qū)域描述"> 
         <el-input type="textarea" :rows="5" v-model="formData.description"></el-input> 
        </el-form-item> 
       </el-col> 
       <el-col :span="2" :offset="9"> 
        <el-button type="success" @click="handleSubmit('formData')" >確定</el-button> 
       </el-col> 
       <el-col :span="2" :offset="1"> 
        <el-button @click="onCancel">取消</el-button> 
       </el-col> 
      </el-form> 
     </el-col> 
    </div> 

2、JS部分

data() { 
  addShow: false //設(shè)置要顯示的頁面部分默認(rèn)為false,隱藏 
  checkdDistributor: null, 
}, 

methods: { 
// 編輯按鈕 
    handleEdit(index,row){ 
      this.checkdDistributor = row; //接受傳參 
      this.addShow = true; // addshow為要顯示的頁面  
    } 
} 
watch: { 
    // 帶參數(shù)編輯 
    checkdDistributor(){ 
      for(let attr in this.formData){ 
        this.formData[attr] = ('' + this.checkdDistributor[attr]); //寫入?yún)?shù) 
      } 
    } 
  }, 

3、最后上效果圖



補(bǔ)充:

vue router-link跳轉(zhuǎn)傳值示例

1、router-link

<router-link :to="{name:'deitail',params:{freezeMon:'2017-10',owerName:'西安'}}" tag="div" >
</router-link>

2、routes路由

export default new Router({
 routes: [
   {
    path: '/',
    name: 'Index',
    component: Index
   },
   {
    path: '/deitail',
    name: 'deitail',
    component: deitail
   }
 ]
})

3、取值

<h1>{{$route.params.freezeMon}}</h1>

4、小結(jié):router-link跳轉(zhuǎn)傳值要注意的地方

* to前面要加:
 * to后面{中的name值要與路由中的name值一致
* 下面的這種方式是錯誤的

<router-link to="{path:'/deitail',params:{freezeMon:'2017-10',owerName:'西安'}}" tag="div" >
</router-link>

相關(guān)文章

最新評論