Skip to content

Commit d2827bf

Browse files
committed
add edit and create demo
1 parent e9d37a9 commit d2827bf

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

src/router/index.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,8 @@ const DynamicTable = () => import('../views/example/table/dynamictable');
5656
const Table = () => import('../views/example/table/table');
5757
const DragTable = () => import('../views/example/table/dragTable');
5858
const InlineEditTable = () => import('../views/example/table/inlineEditTable');
59-
const Form1 = () => import('../views/example/form1');
59+
60+
const Form = () => import('../views/example/form');
6061

6162
/* permission */
6263
const Permission = () => import('../views/permission/index');
@@ -205,7 +206,8 @@ export const asyncRouterMap = [
205206
{ path: 'table', component: Table, name: '综合table' }
206207
]
207208
},
208-
{ path: 'form1', component: Form1, name: '综合form1' }
209+
{ path: 'form/edit', component: Form, name: '编辑form', meta: { isEdit: true } },
210+
{ path: 'form/create', component: Form, name: '创建form' }
209211
]
210212
},
211213
{ path: '*', redirect: '/404', hidden: true }

src/views/example/form1.vue renamed to src/views/example/form.vue

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
<div style="display:inline-block">
88

99
<el-dropdown trigger="click">
10+
<router-link style="margin-right:15px;" v-show='isEdit' :to="{ path:'create'}">
11+
<el-button type="info">创建form</el-button>
12+
</router-link>
1013
<el-button>{{!postForm.comment_disabled?'评论已打开':'评论已关闭'}}<i class="el-icon-caret-bottom el-icon--right"></i></el-button>
1114
<el-dropdown-menu class="no-padding no-hover" slot="dropdown">
1215
<el-dropdown-item>
@@ -185,10 +188,16 @@
185188
computed: {
186189
contentShortLength() {
187190
return this.postForm.content_short.length
191+
},
192+
isEdit() {
193+
return this.$route.meta.isEdit // 根据meta判断
194+
// return this.$route.path.indexOf('edit') !== -1 // 根据路由判断
188195
}
189196
},
190197
created() {
191-
this.fetchData();
198+
if (this.isEdit) {
199+
this.fetchData();
200+
}
192201
},
193202
methods: {
194203
fetchData() {

0 commit comments

Comments
 (0)