vue后台文章编辑功能

后台文章需要编辑功能,本人没有做过,所以就请教了这个小哥哥‘I LEFT YOU LAST’,他给了思路

  • 通过‘跳转页面获取本条数据的id’,并携带这个id跳转到目标页面
  • 目标页面接收这个id,然后通过查询这个id的数据接口获取这个id的数据

代码

路由配置

{	path: '/edit-page/:id',component: EditPage ,props:true },

跳转页面:

<el-table-column prop="address" label="操作">
  <template slot-scope="scope">
    <el-button type="primary" icon="el-icon-edit" @click="handleEdit(scope.row.article_id)">编辑</el-button>
    <el-button type="danger" icon="el-icon-delete" @click="handleDel(scope.row.article_id)">删除</el-button>
  </template>
</el-table-column>
<!-- 这里的id是我数据接口,文章的id -->

methods 

handleEdit(article_id){
  this.$router.push(`/edit-page/${article_id}`)
},
// 这里的id是文章的id

目标页面

		props:{
			id:{}
		},
		data() {
			return {
				iddata:{},
				form:{},
				options: [],
				upload_name: 'file',
				file:[],
			}
		},

methods

			selId(){
				//获取传递过来的id
				let id = this.id
				//根据id来查询数据
				articId(id).then(res =>{  // 这里是接口
					this.form = res.msg[0]  // 因为查询到的数据不是一个对象,而是数组所以这样写了
					console.log(this.form)
				})
			},

created

		created() {
			this.selId()
		},

效果

 

 

 

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值