我也不知道为什么,我用parms传递传输就是不对,难受
下面是代码
显示数据的页面
//这个是点击事件,用来传递参数
<el-button size="mini" style="margin-right: 2px" type="text" @click.native.prevent="getId(scope.row.id,scope.row.scripttitle,scope.row.scriptcontent)">
编辑
</el-button>
//下面是methods中的方法
getId(id,scripttitle,scriptcontent){
this.$router.push({
path:'/broad/manuscript/scriptedit', //这个是你要跳转的路径
query:{ //我用是的query方式,不知为啥params方法不行
id : id,
scripttitle : scripttitle,
scriptcontent : scriptcontent,
}
})
}
下面是回显数据的代码
export default{
created(){
this.getParams()
},
watch: {
'$route': 'getParams'
},
methods: {
getParams () {
// 取到路由带过来的参数
const id = this.$route.query.id;
const _this = this;
_this.form.scripttitle = this.$route.query.scripttitle;
_this.form.scriptcontent = this.$route.query.scriptcontent;
// 将数据放在当前组件的数据内
}
}
}