handleEdit(index, row) {
// let id = row._id
this.$router.push({name: 'news-edit', params : {
new : row
}, query: {id: row._id, type: 'edit'}})
},
让 let id = row._id ,显示id=undefined 但是row._id是有值得 不知道为啥
mounted() {
debugger
console.log(this.$route.query.type)
if ( "edit" == this.$route.query.type ){
let old = this.$route.params.new
this.title = old.title
this.author = old.author
this.content = old.content
this.abstract = old.abstract
this.coverImage = old.coverImage
}
console.log(this.title)
},
old也是同样问题 导致下面的title啥的都获取不到
params参数要在路由中声明。比如url是/newsedit,后面要穿一个叫new的params参数,那路由里要声明:
不然的话你页面刷新后 这个new值就获取不到了。
query参数的话可以不声明。