要實現一個功能:從頁面A跳轉到頁面B,而且頁面A的參數要傳遞到頁面B,B使用傳過來的參數。html
從A到B。
this
其實就是2步走:1,A傳遞參數。2,B接受參數。日誌
在A頁面的對應按鈕,寫上一個方法,點擊的時候調用這個方法,進行跳轉。code
# content of A <el-button size="mini" icon="el-icon-zoom-in" @click.native="goto_report_log(scope.row.job_name)">查看報告&日誌 </el-button> ... ... # 寫上對應的方法 goto_report_log(job_name) { // 點擊跳轉到報告頁 this.$router.push( { path: '/manage/testReportAndLogo', query: { job_name: job_name } } ) }
這時候,點擊按鈕就能夠調轉到B頁面了。orm
首先,頁面B的html對應的字段要添加好,這是前提。router
<el-form-item label="Job名稱" labelWidth="110px"> <el-input placeholder="輸入job名稱" v-model="this.job_name"> #使用拿到的值 </el-input> </el-form-item> ... ... export default { data() { return { job_name: "", # 存放A傳過來的值 ... ... # 接着寫上對應的方法 methods: { getParams() { this.job_name = this.$route.query.job_name # 這裏能夠用this.$route.query拿到值 ... ... created() { this.getParams(); # 放在created裏調用便可 },
很簡單,作個記錄。htm